GridControl with CellType = TextBox

Hello there.
My question is how to catch the "enter" key pressing while a cell is in TextBox mode?
The point is that my grid is readonly by default, but sometimes I need to let the user to edit a cell, and get the content by pressing "enter" key.

Thanx.

2 Replies

LS Lingaraj S Syncfusion Team August 26, 2009 11:45 AM UTC

Hi Erlan,

Thank you for your interest in Syncfusion products.

Please try using CurrentCellKeyDown event in GridControl to achieve this functionality.

Refer the code below:

######### C# Code
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (this.gridControl1.CurrentCell.Renderer.StyleInfo.CellType == "TextBox")
{
if (e.KeyCode == Keys.Enter)
{ // Catch the Enter key
// perform the function
}
}
}
######### VB Code
AddHandler gridControl1.CurrentCellKeyDown, AddressOf gridControl1_CurrentCellKeyDown
Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If Me.gridControl1.CurrentCell.Renderer.StyleInfo.CellType Is "TextBox" Then
If e.KeyCode = Keys.Enter Then
' perform the function
End If
End If
End Sub


Please let me know if you have any queries.

Regards,
Lingaraj S.


EB Erlan Bekenov August 28, 2009 04:32 AM UTC

Hello.
Yeah, it works, thanx a lot!

Loader.
Up arrow icon