I have a datagrid containing two columns. The first column is not editable the second is editable. What I want is, that after loading my form the datagrid has the focus and I can start to enter my data without clicking anywhere.
This is how I tried it:
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal msg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Boolean '[.....] Dim dgc As New DataGridCell(0, 1) Dim dgtb As DataGridTextBoxColumn 'do something Me.grdData.Focus() Me.grdData.CurrentCell = dgc dgtb = CType(Me.grdData.TableStyles(IBS_Vorschau.objDataSetVorschau.strTableName).GridColumnStyles(1), DataGridTextBoxColumn) dgtb.TextBox.Focus() dgtb.TextBox.Select() SendMessage(dgtb.TextBox.Handle, 512, vbNull, vbNull) SendMessage(dgtb.TextBox.Handle, 513, vbNull, vbNull)
At least this lets the user move through the cells using the arrow keys. Enter data right from the beginning isn't possible and another problem is, that I have to click twice on my toolbarbuttons.
Any idea?


Reply With Quote