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:
  1. 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
  2.  
  3. '[.....]
  4.  
  5. Dim dgc As New DataGridCell(0, 1)  
  6. Dim dgtb As DataGridTextBoxColumn  
  7.  
  8. 'do something
  9.  
  10. Me.grdData.Focus()
  11. Me.grdData.CurrentCell = dgc
  12.  
  13. dgtb = CType(Me.grdData.TableStyles(IBS_Vorschau.objDataSetVorschau.strTableName).GridColumnStyles(1), DataGridTextBoxColumn)
  14. dgtb.TextBox.Focus()
  15. dgtb.TextBox.Select()
  16.  
  17. SendMessage(dgtb.TextBox.Handle, 512, vbNull, vbNull)
  18. 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?