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.

GridControl with CellType = TextBox

Thread ID:

Created:

Updated:

Platform:

Replies:

89461 Aug 25,2009 07:44 AM Aug 28,2009 12:32 AM Windows Forms 2
loading
Tags: GridControl
Erlan Bekenov
Asked On August 25, 2009 07:44 AM

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.

Lingaraj S [Syncfusion]
Replied On August 26, 2009 07:45 AM

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.

Erlan Bekenov
Replied On August 28, 2009 12:32 AM

Hello.
Yeah, it works, thanx a lot!

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.

;