Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridView Keypress problem
 

DataGridView Keypress problem

I am using the DataGridView control in Windows.Net. And using the Keypress event

Private Sub grdTimeSeries_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles grdTimeSeries.KeyPress

Dim KeyAscii As Short = Asc(e.KeyChar)

If KeyAscii = 13 Then

----some code

Endif

End Sub

When I am pressing the enter key selecting row number 1 and pointer goes to second rows automatically and row index also returns 2. Can you please tell me why it is happening and also the way to stop this..

Please suggest

Anonymous261977  Tuesday, November 13, 2007 12:50 PM
Basically the datagridview is handling the enter key press and not letting it go to the keypress event. You need to create a control that inherits from datagridview and override the PreProcessMessage to change the behavior of the enter key. Here is an example which sould help

http://www.vb-tips.com/DatagridViewEnter.aspx

Ken Tucker  Tuesday, November 13, 2007 7:47 PM
Basically the datagridview is handling the enter key press and not letting it go to the keypress event. You need to create a control that inherits from datagridview and override the PreProcessMessage to change the behavior of the enter key. Here is an example which sould help

http://www.vb-tips.com/DatagridViewEnter.aspx

Ken Tucker  Tuesday, November 13, 2007 7:47 PM

You can use google to search for other answers

Custom Search

More Threads

• How to read the data in textbox by using datareader
• Failed to enable constraints when filling data tables.
• BindingSource cannot be its own data source
• Combobox bound to an ArrayList in databound grid
• Deleting row from windows datagrid.
• DataGridViewComboBoxCell Value is not Valid
• Problem with DataGridBoolColumn
• Adding a record to DataGridView while using BindingDataSource and TypedDataSet
• Parent/Child-Save options
• how can we insert dropdown list in dataGrid in VB.NET