We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to use arrow keys in combobox

Hi, I have some problems with Tab/Enter and arrow keys in GridDataBoundGrid. Please help me! 1)When a combobox cell in GridDataBoundGrid is activated, how to use arrow keys to change the value of combobox? 2) all colums in GridDataBoundGrid are readonly except the column having combobox cell. How to use Tab key to jump from a combobox cell in a row to the one in other rows (next rows)?. How to prevent the activation on readonly column? 3) To selectALl the text of cell in GridDataBoundGrid, I use the following code: tb.SelectionStart = tb.Text.Length; tb.SelectionLength = 0; SendKeys.Send("+({HOME})"); So that I can not use the event CurrentCellControlKeyDown to get the ''TAB'' key. I always get the ''HOME'' key. Do you have any suggestion on these things? Thank you!

4 Replies

AD Administrator Syncfusion Team February 24, 2005 12:10 PM UTC

1) In the grid\Samples\DataBound\GDBGcombos sample, the up/down arrow keys work to move the selection as expected for me. Are you handling any events (maybe CurrentCellChanged) that might interfere with this default behavior? 2) Set the style.Enabled = false for your readonly columns. This should prevent them from ever becoming the current cell. If you want the tab to wrap to the next row, set this property. this.grid.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; 3) If you always want to seelct all the text when a cell becomes the current cell, try setting this property. this.grid.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;


DA DavidBosak@venturipartners.com February 25, 2005 01:51 AM UTC

for 1) I meant that I really want to use arrow keys (Up and Down) to change the value in the current cell (combobox cell), not move the selection. Please help me! >1) In the grid\Samples\DataBound\GDBGcombos sample, the up/down arrow keys work to move the selection as expected for me. Are you handling any events (maybe CurrentCellChanged) that might interfere with this default behavior? > >2) Set the style.Enabled = false for your readonly columns. This should prevent them from ever becoming the current cell. If you want the tab to wrap to the next row, set this property. >this.grid.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow; > >3) If you always want to seelct all the text when a cell becomes the current cell, try setting this property. >this.grid.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll; >


AD Administrator Syncfusion Team February 25, 2005 09:08 AM UTC

>>for 1) I meant that I really want to use arrow keys (Up and Down) to change the value in the current cell (combobox cell), not move the selection. Please help me! Did you look at the sample. When I said move teh selection, I meant that it moves the selection in the combobox when it is dropped. It does not move the current cell from one position in the grid to amother. So, if the combobox is dropped, the up/down arrow change the value in the cell. Are you seeing this behavior? If this is what you want, it is the default behavior in that sample. Do you also want the arrows to change the value of the cell when it is not dropped? In this case, I was able to get this to work in that sample by adding these two event handlers. private void gridControl1_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e) { Keys keyCode = (Keys) ((int)e.Msg.WParam) & Keys.KeyCode; if(keyCode == Keys.Down || keyCode == Keys.Up) { Console.WriteLine("CurrentCellControlKeyMessage"); e.CallProcessKeyPreview = false; e.CallBaseProcessKeyMessage = true; } } private void gridControl1_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { GridCurrentCell cc = this.gridControl1.CurrentCell; GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if(cr != null) { Console.WriteLine("KeyDown"); ListBox lb = cr.ListBoxPart; if(e.KeyCode == Keys.Down && lb.SelectedIndex < lb.Items.Count - 1) { lb.SelectedIndex += 1; } else if(e.KeyCode == Keys.Up && lb.SelectedIndex > 0) { lb.SelectedIndex -= 1; } //cr.Control.Text = lb.SelectedItem.ToString(); if(lb.SelectedItem is DataRowView) { DataRowView drv = lb.SelectedItem as DataRowView; cr.SetTextBoxText(drv[lb.DisplayMember].ToString(), false); } else { cr.SetTextBoxText(lb.SelectedItem.ToString(), false); } cr.EditPart.SelectAll(); e.Handled = true; } } }


DA DavidBosak@venturipartners.com February 25, 2005 10:57 AM UTC

Thank you very much!

Loader.
Live Chat Icon For mobile
Up arrow icon