.NETGURU
Can I do this - Control Focus despite Tab Order ?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

JB
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
Reply to this message...
 
    
Imran Koradia (VIP)
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.

"JB" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
JB
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

"Imran Koradia" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
 
System.EventArgs




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification