Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulating Enter key in Windows datagrid 2

Status
Not open for further replies.

ditrex

Programmer
Nov 26, 2002
7
NL
In the past I used to built applications in Clipper for DOS and I used datagrids where all the keys could be manipulated. For instance, when a user hits the Enter key the cursor moeved to the next cell in the row. In certain columns when hitting a key I started a special function for instance another form to Enter some Data.
I know nowadays everything works with mouse clicks, but a lot of my customers, due to RSI etc., prefer using the keyboard to perform certain functions. So my question is:
How can I set the Enter key (or other keys) in VB.NET to perform certain actions, like moving the cursor to another cell, row, etc.
 
You can subclass the datagrid and then overload the event handler:
------------------------------------------------
Public Class DataGrid_Custom
Inherits DataGrid
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Enter Then
MessageBox.Show("You pressed enter")
End If
Retrun MyBase.ProcessCmdKey(msg, keyData)
End Function
End Class
---------------------------------------------

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top