Home Forums WinForms controls Xceed Grid for WinForms How can I get a KeyCode while edit a cell in vb.net Reply To: How can I get a KeyCode while edit a cell in vb.net

User (Old forums)
Member
Post count: 23064

You can handle the QueryInputKey event on the Column’s CellEditorManager :

foreach( Column col in gridControl1.Columns )

{

    col.CellEditorManager.QueryInputKey +=

new QueryEditorInputKeyEventHandler(CellEditorManager_QueryInputKey);

}

void CellEditorManager_QueryInputKey( object sender, QueryEditorInputKeyEventArgs e )

{

    System.Diagnostics.

Debug.WriteLine( e.KeyData.ToString() );

Note however that when a key is press to enter edition (instead of a mouse click), the first key will not be processed by this event, so you need to handle the KeyPress on the cell itself to get the first key :

foreach( Cell cell in dataRowTemplate1.Cells )

{

    cell.KeyPress +=

new KeyPressEventHandler( cell_KeyPress );

void cell_KeyPress( object sender, KeyPressEventArgs e )

{

    System.Diagnostics.

Debug.WriteLine( e.KeyChar.ToString() );

}

 

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