I have a usercontrol
When this control receives focus, it should change to the user defined color held in a public variable, which it does. In my forms, I have a routine that binds all controls Enter event to a single sub:
In OnSetFocus, if the key field is entered and the user presses enter or tabs to the next control, if it is an inherited textbox, the text is highlighted even if the clear property is set to false. This only happens on the first textbox after the key textbox.
After debugging, I find that the base class On_Enter event of ritext is fired, then the forms OnSetFocus is fired populating the form's fields and highlighting the inherited textboxes text.
If I add the call sender.On_Enter(Sender, e) in the form's OnSetFocus routine, it "works" like it is supposed to, but every time a textbox receives focus it is calling the base class twice.
Any suggestions are appreciated.
Code:
Public Class Ritext
Inherits System.Windows.Forms.TextBox
When this control receives focus, it should change to the user defined color held in a public variable, which it does. In my forms, I have a routine that binds all controls Enter event to a single sub:
Code:
AddHandler c1.Enter, AddressOf Me.OnSetFocus
In OnSetFocus, if the key field is entered and the user presses enter or tabs to the next control, if it is an inherited textbox, the text is highlighted even if the clear property is set to false. This only happens on the first textbox after the key textbox.
After debugging, I find that the base class On_Enter event of ritext is fired, then the forms OnSetFocus is fired populating the form's fields and highlighting the inherited textboxes text.
Code:
Public Sub On_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Enter
Try
sender.BackColor = Color.FromArgb(255, InRGB)
msSavedText = Me.Text
If IsNothing(DirectCast(sender, Ritext).RICSFormLabel) Then
DirectCast(sender, Ritext).RICSFormLabel.Text = ""
End If
Catch ex As Exception
End Try
Try
If _RICSClear Then
DirectCast(sender, Ritext).SelectAll()
Else
If DirectCast(sender, Ritext).Text.Length > 0 And DirectCast(sender, Ritext).SelectionLength = 0 And (DirectCast(sender, Ritext).SelectionStart = 0 Or DirectCast(sender, Ritext).SelectionStart = DirectCast(sender, Ritext).Text.Length) Then
DirectCast(sender, Ritext).SelectionStart = DirectCast(sender, Ritext).Text.Length
End If
End If
Catch ex As Exception
Finally
_dtEntered = Now
End Try
End Sub
If I add the call sender.On_Enter(Sender, e) in the form's OnSetFocus routine, it "works" like it is supposed to, but every time a textbox receives focus it is calling the base class twice.
Any suggestions are appreciated.