Hi Foef
Thank you very much for your solution. Can you tell me how can i use your
code into my existing project. The code is as below. I'm sorry because I'm
new to VB.NET. I'm using Visual Studio ver 7.1. Is there any sample code I
can download.
Pls help. Thanks.
Regards
Steve
Imports System.Data
Imports System.Data.Ole Db
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' create a connection string
Dim connString As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\\Nort hwind.mdb"
Dim myConnection As OleDbConnection = New OleDbConnection ()
myConnection.Co nnectionString = connString
' create a data adapter
Dim da As OleDbDataAdapte r = New OleDbDataAdapte r("Select * from
Customers", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet()
' fill dataset
da.Fill(ds, "Customers" )
' Attach DataSet to DataGrid
DataGrid1.DataS ource = ds.DefaultViewM anager
End Sub
End Class
"Foef" <Fo**@discussio ns.microsoft.co m> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Steve,
To capture keypress event in a datagrid you should use the ProcessCmdKey
function.
for example:
Public Class MyDataGrid
Inherits DataGrid
Protected Overrides Function ProcessCmdKey(B yRef msg As
System.Windows. Forms.Message, keyData As System.Windows. Forms.Keys) As
Boolean
If msg.WParam.ToIn t32() = CInt(Keys.Enter ) Then
SendKeys.Send(" {Tab}")
Return True
End If
OR
Const WM_KEYDOWN As Integer = &H100
Const WM_SYSKEYDOWN As Integer = &H104
If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
Select Case (keyData)
Case (Keys.Control Or Keys.M)
Case (Keys.Alt Or Keys.Z)
Case Keys.Delete
End Select
End If
Return MyBase.ProcessC mdKey(msg, keyData)
End Function 'ProcessCmdKey
End Class 'MyDataGrid
Greetinx,
Foef
"Melson" wrote:
hi
can anyone help me how can i capture ENTER keystroke when the cell in
datagrid is in editing mode.
I'm now creating a data entry form with primary key in header and details
in
datagrid. So when user key in the details in datagrid, I would like user
to
choose product code by pressing ENTER key in the datagrid and a Product
Code
dialog will appear for him to choose.
Pls help. Thanks very much.
Regards
Steve