|
-
Nov 7th, 2002, 11:42 AM
#1
Thread Starter
Addicted Member
Set Focus in Textbox
How do you set focus on a textbox???? Seems like it should be easy, but...
-
Nov 7th, 2002, 12:41 PM
#2
Hyperactive Member
Make sure the form is visible before executing the method.
-
Mar 12th, 2003, 03:20 PM
#3
Frenzied Member
is the form visible on the page load event?
-
Mar 13th, 2003, 10:11 AM
#4
Hyperactive Member
Ive found occasional problems with setting focus in the form_load event.
To get around this I have processed the set focus from a timer that is enabled by the form_load event and dis-enabled after it processes once.
-
Mar 13th, 2003, 05:45 PM
#5
Lively Member
I use this event to set the focus to a textbox on the form load. It seems to work ok for me.
Code:
Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
If (Me.txtDataFormat.Enabled = True) Then
'Set the focus to the txtDataFormat textbox otherwise
'set it to the txtDisplay textbox
Me.txtDataFormat.Focus()
Else
'Set the focus to the txtDisplay textbox
Me.txtDisplay.Focus()
End If
End Sub
-
Mar 14th, 2003, 12:42 AM
#6
Member
txt1.focus()
its easier and faster
i will be come a better programmer some day! thanks to vbforums.com
-
Mar 16th, 2003, 11:12 AM
#7
Frenzied Member
yeah, it is quicker but it doesn't work on the load of the page...you have to put txt1.focus in the code where you call the new page from...put it after frm1.show...
-
Mar 17th, 2003, 03:50 PM
#8
Frenzied Member
You could always set the text box to be the first item in the tab order, and then it'll have focus automatically when the form starts.
~Peter

-
Apr 24th, 2004, 05:54 AM
#9
Junior Member
This only happens in VS.net 2002, it is fixed in vs.net 2003.
Took me a few days to discover !!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|