This behavior is due to the DataGridViewComboBoxCell's property - "IsNullValueDefault". As soon as you press delete or backspace key, the value you selected is set to null and because of the above property, the DGV changes the selected value from null to the default value.
To overcome this problem, you can override the ProcessDialogKey method as follows:
protected override bool ProcessDialogKey(Keys keyData)
{
if (this.Rows[rowNo].Cells[colNo].GetType().Name.Equals("Datagridviewcomboboxcell", StringComparison.OrdinalIgnoreCase) && ((key == Keys.Delete) || (key == Keys.Back)))
return true;
return base.ProcessDialogKey(keyData);
}
mrstrong wrote:
Delete key in DataGridViewComboBoxCell
23-Sep-07
I have a DataGridViewComboBoxCell in a DataGridView. When it is
selected and
the user presses Delete key it is reseted to default value (or first
value in
ComboBox).
How can I override this default b
Previous Posts In This Thread:
Delete key in DataGridViewComboBoxCell
I have a DataGridViewComboBoxCell in a DataGridView. When it is
selected and
the user presses Delete key it is reseted to default value (or first
value in
ComboBox).
How can I override this default b
Re: Delete key in DataGridViewComboBoxCell
mrstrong,
Look into the ProcessCmdKey method
Brendon
EggHeadCafe - Software Developer Portal of Choice
SQL Server - Insert Record And Get New ID
http://www.eggheadcafe.com/tutorial...7c-aa271ab7302a/sql-server--insert-recor.aspx