Tab KeyPress in Form_Load Programmatically?

skaryChinezeGuie

Well-known member
Joined
Apr 23, 2006
Messages
94
Programming Experience
Beginner
how do i program a tab keypress in a form load? I have a web browser on my form and i need to hit tab twice so that the correct box is selected on the web page.:D
 
You have to do it after the form is shown and document in webbrowser is completed, else the keying won't affect the displayed controls, if the webbrowser control is in focus you can then use the code below, I would put it in Document_Complete event of AxWebbrowser (since you're .Net1):
VB.NET:
SendKeys.Send("{TAB}{TAB}")
Also there is the standard code there to 'do once' on document completed when e.ppdisp is webbrowser.application. So it should be something like:
VB.NET:
sub axwebbrowser1_documentcomplete(sender, e) _
handles axwebbrowser1.documentcomplete
  if e.ppdisp = webbrowser.application then
    SendKeys.Send("{TAB}{TAB}")
  end if
end sub
Alternative is in documentcomplete event to hook into the Dhtml and use the Focus method on the element.
 
Back
Top