By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Using up and down arrow keys in datagridview

P: n/a

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);
}
May 30 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.