Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

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?

  • 2 months later...
Posted

I had the exact same situation. I have a small page that loads with a datagrid on it, which I wanted to always default to the first textbox in the footer for data entry. While I haven't gotten the ENTER key to function to process the entry command from anywhere on the page, I do have code that should help you.

 

I posted it on the http://www.asp.net forums..here is the link

 

http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=206488

 

Hope this helps.

 

-Kirk

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...