_Tommy_b
asked on
Passing an object using Add event handler
I have a form were there a number of textboxes which are created on a form dynamically, the number of which varies according to initial parameters.
Due to the nature of data that the user has to input the text must be formatted to a set format on the 'textbox.leave' event
the attached code works perfectly for this textbox as there is no requirement for information from the textbox that raised the event. Is there some way to use a method like the 'Directcast()' method to obtain properties from the textbox which triggered the event?
Thanks,
Thomas
Due to the nature of data that the user has to input the text must be formatted to a set format on the 'textbox.leave' event
the attached code works perfectly for this textbox as there is no requirement for information from the textbox that raised the event. Is there some way to use a method like the 'Directcast()' method to obtain properties from the textbox which triggered the event?
Thanks,
Thomas
'' This code in in the form.load eventArg after the code that creates the synamic textboxes
For Each ctl As Control In Me.Controls
If TypeOf ctl Is TextBox Then
AddHandler ctl.Leave, AddressOf tbleave
End If
Next
End Sub
Sub tbleave()
MessageBox.Show("The user has left this textbox")
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To be honest I'm a little surprised the complier didn't pick up on it, the C# compiler would have complained about the method not matching the expected signature.
ASKER
Thanks Carl :)