Home Forums WinForms controls Xceed Grid for WinForms Trapping Up and Down Key

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15286 |

    Hi
    How do you trap the up and down key ?

    Imported from legacy forums. Posted by Graeme (had 1815 views)

    User (Old forums)
    Member
    Post count: 23064

    When editing a cell, you need to subscribe to the editor events through the ActivatingControl event of the CellEditorManager. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.

    e.g.:
    <code>
    //at Form_Load

    private void Form1_Load(object sender, System.EventArgs e)
    {
    gridControl1.Columns[ 0 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager0_ActivatingControl);
    gridControl1.Columns[ 0 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager0_DeactivatingControl);

    //Event handlers

    private void CellEditorManager0_ActivatingControl(object sender, CellEditorEventArgs e)
    {
    //here you can subscribe to KeyUp or KeyDown events.
    ( ( WinTextBox )e.Control).TextBoxArea.DoubleClick += new EventHandler(TextBoxArea_DoubleClick);
    }

    private void CellEditorManager0_DeactivatingControl(object sender, CellEditorEventArgs e)
    {
    //need to unsubscribe, if not, the subscriptions will kept pilling up!
    ( ( WinTextBox )e.Control).TextBoxArea.DoubleClick -= new EventHandler(TextBoxArea_DoubleClick);
    }

    private void TextBoxArea_DoubleClick(object sender, EventArgs e)
    {
    System.Diagnostics.Debug.WriteLine( sender.ToString() );
    }
    </code>

    Imported from legacy forums. Posted by André (had 2895 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.