SetFocus

  • Thread starter Thread starter Nice Chap
  • Start date Start date
N

Nice Chap

On Form Load Setting focus to a specific field does not work { I guess
becuase the handle is not created yet}what event should I then use to set
focus to a particular field on a form.

Activated changes the focus 'every' the form gets activated which in my case
is undesirable.

Has anybody encountered this problem at all please ?
 
On Form Load Setting focus to a specific field does not work { I guess
becuase the handle is not created yet}

No - the controls have already been created; you can't set focus because the
controls are still invisible.
Activated changes the focus 'every' the form gets activated which in my case
is undesirable.

you're on track. You can use a boolean to tell you whether this is the first
time a form is activated.
something like this:

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 that helps..
Imran.
 
Thanks for your reply,

just for the benefit of others,


On Load, setting Me.ActiveControl to the desired textbox works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top