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.
Unfortunately, activation email could not send to your email. Please try again.

How to use arrow keys in combobox

Thread ID:

Created:

Updated:

Platform:

Replies:

25316 Feb 24,2005 06:05 AM Feb 25,2005 05:57 AM Windows Forms 4
loading
Tags: GridControl
DavidBosak@venturipartners.com
Asked On February 24, 2005 06:05 AM

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!

Administrator [Syncfusion]
Replied On February 24, 2005 07:10 AM

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;

DavidBosak@venturipartners.com
Replied On February 24, 2005 08:51 PM

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; >

Administrator [Syncfusion]
Replied On February 25, 2005 04:08 AM

>>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; } } }

DavidBosak@venturipartners.com
Replied On February 25, 2005 05:57 AM

Thank you very much!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;