|
-
Apr 15th, 2005, 01:31 AM
#1
Thread Starter
Member
How to set focus to one control when a form pop up?
hello guys, i want to set focus to a textbox when the form pop up so that the user can enter directly instead of first pointing to the textbox then entering..
I tried put textbox1.focus() in the form_load event, but it doesn't work. anybody know how to deal with it?
cheers
Last edited by sunsunlight; Apr 17th, 2005 at 09:25 PM.
-
Apr 15th, 2005, 02:12 AM
#2
Frenzied Member
Re: How to set focus to one control when a form pop up?
Try disabling it and enabling it?
-
Apr 15th, 2005, 02:18 AM
#3
Re: How to set focus to one control when a form pop up?
 Originally Posted by sunsunlight
hello guys, i want to set focus to a textbox when the form pop up so that the user can enter directly instead of first pointing to the textbox then entering..
I tried put textbox1.focus() in the form_load event, but it doesn't work. anybody know how to deal with it?
cheers
-
Apr 15th, 2005, 02:24 AM
#4
Thread Starter
Member
Re: How to set focus to one control when a form pop up?
textbox1.select!
it works!
tks!
-
Apr 15th, 2005, 02:59 AM
#5
Re: How to set focus to one control when a form pop up?
If you set the tab order correctly, the first item (0 or 0.0 if using groupboxes) will be the first control to have focus.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Apr 15th, 2005, 07:19 AM
#6
Re: How to set focus to one control when a form pop up?
 Originally Posted by Ideas Man
If you set the tab order correctly, the first item (0 or 0.0 if using groupboxes) will be the first control to have focus.
if your control is in a GroupBox, so the Groupbox it must have a tab index smaller than the controls in it ...
-
Apr 19th, 2005, 09:14 AM
#7
Frenzied Member
Re: How to set focus to one control when a form pop up?
what is the difference between
and
i have always tried text1.focus , and it didn't work for the first time with the form.
strange, any1 got explanation ??
thx
-
Apr 20th, 2005, 09:02 AM
#8
Re: How to set focus to one control when a form pop up?
 Originally Posted by Zakary
if your control is in a GroupBox, so the Groupbox it must have a tab index smaller than the controls in it ...

I didn't quite understand that sorry.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Apr 20th, 2005, 05:57 PM
#9
Frenzied Member
Re: How to set focus to one control when a form pop up?
I didn't quite understand that sorry.
well that means if you have a textbox in a groupbox inside your form.
you cannot set the tabindex of your textbox to 0 , why ?? because it is contained in a group box that must has a smaller tabindex than the tabindex of it's contained controls.
-
Apr 20th, 2005, 09:44 PM
#10
New Member
Re: How to set focus to one control when a form pop up?
With textbox, you can use SelectAll() method to select all text in that textbox.
Code:
with txt1
.focus()
.selectall()
end with
-
Apr 21st, 2005, 01:46 AM
#11
Re: How to set focus to one control when a form pop up?
 Originally Posted by maged
well that means if you have a textbox in a groupbox inside your form.
you cannot set the tabindex of your textbox to 0 , why ?? because it is contained in a group box that must has a smaller tabindex than the tabindex of it's contained controls.
No, that's not true at all. When you create groupboxes it groups all the controls together, along with their tab orders. You then must specify a "tab order" for the groupboxes, and then the controls inside it.
The tab order for the groupboxes specifies in what order the groups of controls are selected, and once a groupbox has "focus", it then works in it's internal list of controls and works on the internal tab order of the controls.
This is why when you have groupboxes, you get a tab order of x.y for controls in a groupbox and x for a groupbox. It's also the reason why it can differentiate between two controls in different groupboxes with the same tab order.
Please note: If this doesn't make sense I'm sorry, I understand how it works, just not quite how to put it into words lol.
Last edited by Ideas Man; Apr 21st, 2005 at 02:55 AM.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
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
|