Custom Control Events... GotFocus and LostFocus not firing.
Posted on 2005-04-08
I'm currently trying to get a custom controls events to fire but for some reason they won't. I'm programmatically adding two custom controls (made by my company's controls group) to a Form. I declared the control as follows...
Private WithEvents RCNWMGC As WealthPoint.CoreControls.Controls.RegularControl
and then I selected the gotfocus and lostfocus events and added code...
Private Sub RCNWMGC_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles RCNWMGC.GotFocus
Dim tmpI As Integer
tmpI = Integer.Parse(RCNWMGC.Text.Substring(1, RCNWMGC.Text.Length - 1))
RCNWMGC.Text = tmpI.ToString("C")
Private Sub RCNWMGC_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles RCNWMGC.LostFocus
RCNWMGC.Text = CType(RCNWMGC.Text, Integer).ToString("C")
When I ran the program the events did not fire. I then removed the "Handles..." text and added these two statements to the startup routine...
AddHandler Me.RCNWMGC.GotFocus, AddressOf RCNWMGC_GotFocus
AddHandler Me.RCNWMGC.LostFocus, AddressOf RCNWMGC_LostFocus
The above statements did not cause the events to fire either. Anyone have any idea why GotFocus and lostFocus aren't firing?
Thanks in advance for your help.