Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Can I do this - Control Focus despite Tab Order ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 01 Sep 2004 23:20 GMT
Using the tab order in VB on a form works fine but to me it seems
tedious (at times) to have to set or be concerned with the tab order.
I can't seem to get a control to have focus on the load form
event...am I doing something wrong or do I just need to control this
thru tab order?

TIA

JB
Imran Koradia - 02 Sep 2004 00:10 GMT
The form is shown only after the last line in the load event is executed.
During the load event, the form is invisible and so are the controls on it.
Focus can only be set on controls that are visible and enabled. So trying to
set focus to a control in the load event wont work. Instead, use the
Activated event of the form to set focus. However, since Activated is fired
everytime the form is activated, you'll have to make sure that you set focus
only the first time it is activated which is after the load event. Something
like this should work for you:

Private bFirstTimeActivated as boolean

Private Sub Form1_Activated(ByVal sender As Object, _
           ByVal e As System.EventArgs) Handles MyBase.Activated
       If Not bFirstTimeActivated Then
           MyControl.Focus()
           bFirstTimeActivated = True
       End If
End Sub

hope this helps..
Imran.

> Using the tab order in VB on a form works fine but to me it seems
> tedious (at times) to have to set or be concerned with the tab order.
[quoted text clipped - 5 lines]
>
> JB
JB - 03 Sep 2004 16:55 GMT
Thanks for the explanation...makes sense.  I'll give your method a
try.

One other thing that I discovered right after I posted my original
message was the "Tab Order" found under the View menu when in Design
mode.  This feature takes the tediousiness out of setting tab order.

JB

> The form is shown only after the last line in the load event is executed.
> During the load event, the form is invisible and so are the controls on it.
[quoted text clipped - 27 lines]
> >
> > JB

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.