|
Question : Disable Enter key in Datagrid
|
|
I have a Datagrid with custom columns. These columns contain textboxes but also comboboxes and checkboxes. Now when a user presses the enter button when editing the values in a textfield column then a Datagrid event will be fired. This is something I totally not want. Is there a way to ignore the Enter key in a Datagrid? If I press enter in a textboxfield then the next row will be selected. I tried to catch the Enter key in the textboxes but it seems like they are overruled by this Datagrid event. Any idea to fix this problem?
|
|
Answer : Disable Enter key in Datagrid
|
|
Maybe a custom DataGrid will solve this:
Put this code in the same namesapce as your Form:
Public Class Jeffr0sDataGrid Inherits DataGrid
Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean If m.Msg = 256 Then Return False End If
Return True End Function End Class
Then change the code that instantiates the Grid like this:
Me.DataGrid1 = New Jeffr0sDataGrid()
(The code for it is in the " Windows Form Designer generated code " area.)
|
|
|