We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Deleguate setfocus method

esohier
esohier asked
on
Medium Priority
230 Views
Last Modified: 2013-12-26
Hi,

I've a usercontrol on VB6 and I would like to know how to deleguate the setfocus method?

Thanks by advance.
Comment
Watch Question

Commented:
What do you mean by "deleguate" (delegate?)

Author

Commented:
Sorry,

I would like to give the method to the form to make this sample:

Sub Form _load

  mycontrol.SetFocus

End Sub
Commented:
Oh, I see.  You want a control to have focus when the form is first displayed (but can't do it in the Form_Load() event, since the controls aren't visible during the load event).

You have two options

1. In design mode, set the TabIndex for the control to 0.  This will cause the control in question to acquire focus automatically when the form is loaded (no code required).

2. Although the Form_Load() event is not a valid place to set the focus of a control, you can put the code in the form's paint event (or even the Activate event).  You shoud set up a static variable so it only hits once (and not every time the form is repainted):

Private Sub Form_Paint()
    Static bSkip As Boolean
    If Not bSkip Then
        mycontrol.SetFocus
        bSkip=True
    End If
End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Very thanks. That Ok.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.