What use OnGotFocus?

  • Thread starter Thread starter Phill. W
  • Start date Start date
P

Phill. W

How am I supposed to use a Control's Overridable On* Methods?
I'm obviously missing something very important about them but they
just don't seem to do anything for me :-(

I have a UserControl which contains, among other things, a TextBox.
I'm trying to override the UserControl's focus-getting behavious such
that, on calling [Control].Focus() - which is probably my problem
- the User Control /intercepts/ this and puts directly focus into the
TextBox.

I've tried handling the GotFocus Event on both the UserControl and
the TextBox, and now overriding the OnGotFocus method, but
(a) I never get focus into my TextBox and
(b) the Focus() method itself returns False, even though it and all
its "parent" controls are both Visible and Enabled.

Any suggestions gratefully received...

TIA,
Phill W.
 
Something like this perhaps:

Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
myTextBox.Focus()
End Sub

Public Overrides ReadOnly Property Focused() As Boolean
Get
Return myTextBox.Focused
End Get
End Property


/claes
 
Back
Top