validating-event
Hello,
Can somebody tell me if it’s possible to get the name of the control (not the container !) that causes validation during the validating-event of a control that I’m leaving.
Thanks,
Hello,
Can somebody tell me if it’s possible to get the name of the control (not the container !) that causes validation during the validating-event of a control that I’m leaving.
Thanks,
You can cast the sender argument in your event handler to Control and get the name:
Private Sub TextBox1_Validating(sender As Object, e As EventArgs) Dim senderControl As Control = CType(sender, Control) senderControl.Name ' Should be TextBox1 End Sub |
Thanks for your answer, but this is not what I’m looking for.
Consider I have a TextBox1 and a Textbox2 (both in different containers).
Textbox 1 has the focus. Now I click (or move with Tab) into Textbox2.
Can I get the name of Textbox2 in the validation-event of Textbox1 ?
Do you have an solution ? Georg
About the name of the control, see in the good book:
http://msdn.microsoft.com/vbrun/staythepath/additionalresources/IntroTo2005/default.aspx
Free Book – Introducing Visual Basic 2005 for Developers
In Chapter 1 – Framework Class Librasry - Namespaces
The author says: Unless other information is provided for the compiler to resolve a class name, classes must be referred to using their fully qualified name. A fully qualified name is the class name preceded by its namespace. If the namespace is nested in another namespace, the full list of namespaces must be included in the fully qualified name. The fully qualified name for the class in the previous example is ChooseYourOwnNamespace.Namespace1.Class1.
If your TextBox are in the same Namespace, in the same Class ou not, but in different Forms, I think that applies to your case.
Sime?o (Pelotas - RS - Brasil)