A
Andrus
I have combobox column in DataGridView.
Up and down error keys should be used to navigate previous and next row in
grid.
For this I override them in ProcessCmdKey() event.
When combobox dropdown menu is open arrow arrow keys should move to previous
and next item in
dropdown menu instead of moving betveen rows.
How to check that combobox dropdown menu is open in ProcessCmdKey() ?
Andrus.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) {
switch (keyData) {
case Keys.Down:
if (this.CurrentCell is DataGridViewComboBoxCell) {
CurrentCell = Rows[CurrentCell.RowIndex +
1].Cells[CurrentCell.ColumnIndex];
return true;
}
break;
case Keys.Up:
if (this.CurrentCell is DataGridViewComboBoxCell) {
CurrentCell = Rows[CurrentCell.RowIndex -
1].Cells[CurrentCell.ColumnIndex];
return true;
}
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Up and down error keys should be used to navigate previous and next row in
grid.
For this I override them in ProcessCmdKey() event.
When combobox dropdown menu is open arrow arrow keys should move to previous
and next item in
dropdown menu instead of moving betveen rows.
How to check that combobox dropdown menu is open in ProcessCmdKey() ?
Andrus.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) {
switch (keyData) {
case Keys.Down:
if (this.CurrentCell is DataGridViewComboBoxCell) {
CurrentCell = Rows[CurrentCell.RowIndex +
1].Cells[CurrentCell.ColumnIndex];
return true;
}
break;
case Keys.Up:
if (this.CurrentCell is DataGridViewComboBoxCell) {
CurrentCell = Rows[CurrentCell.RowIndex -
1].Cells[CurrentCell.ColumnIndex];
return true;
}
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}