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.
Syncfusion Feedback

Moving inside a control using <- or -> in a grid

Thread ID:

Created:

Updated:

Platform:

Replies:

44601 May 29,2006 02:21 PM UTC May 30,2006 08:01 AM UTC Windows Forms 2
loading
Tags: GridControl
Borja
Asked On May 29, 2006 02:21 PM UTC

Hi, I use a GDBG and i have a combobox control as a control in one of the cells. The problem is that if i''m writting something in the combobox and i use the cursor keys <- (left) or -> (right), the focus goes to the previous or next cell instead of moving the cursor inside the combobox. How can i make the key event to target the combobox instead of the datagrid? Thank you Borja

Administrator [Syncfusion]
Replied On May 30, 2006 04:06 AM UTC

Hi Borja, There is no built-in support for this. Could you try this code in Grid Style''s Control.KeyDown event. e.Style.Control.KeyDown +=new KeyEventHandler(Control_KeyDown); private void Control_KeyDown(object sender, KeyEventArgs e) { ComboBox combo = sender as ComboBox; if(combo.Focused) { if(e.KeyData == Keys.Left) { this.gridDataBoundGrid1.CurrentCell.MoveLeft(); e.Handled = true; } else if(e.KeyData == Keys.Right) { this.gridDataBoundGrid1.CurrentCell.MoveRight(); e.Handled = true; } } } Here is a sample. http://www.syncfusion.com/Support/user/uploads/ComboGDBG_c16e5602.zip Let me know if this helps. Best Regards, Haneef

Borja
Replied On May 30, 2006 08:01 AM UTC

Hi Haneef, Actually my problem is the other way around: the combo has the focus and when i press -> (or <-) i want the cursos to move right (or left) in the text of the combobox, but instead of that the next (or previous) cell gets the focus. I''ve a few tests implementing the combo''s KeyDown event as in the example, but when these keys (any special key) are pressed this event doesn''t get fired (grid_keydown is fired instead). Finally i''ve got a solution this way (implementing grid''s KeyDown event instead of combo''s KeyDown event): void gridDataBoundGrid1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (oCombo.Focused) { int position = oCombo.SelectionStart + oCombo.SelectionLength; if (e.KeyData == Keys.Left) { oCombo.SelectionLength = 0; if (position > 0) oCombo.SelectionStart = position - 1; e.Handled = true; } else if (e.KeyData == Keys.Right) { oCombo.SelectionLength = 0; if (position < oCombo.Text.Length) oCombo.SelectionStart = position + 1; else oCombo.SelectionStart = position ; e.Handled = true; } } } Thank you

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.

Warning Icon 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.Close Icon

;