Hi!
I need to get a string containing a specified control full location namespace...
Explaining it better, imagine this:
MyProject +-> MyForm1 +-> TabControl1 +-> TabPage1 +-> Button1
Giving the Button1 object as a parameter, I need to have a function that can retrieve me:
"MyProject.MyForm1.TabControl1.TabPage1.Button1"
My current solution looks like this:
I was hoping that there were a solution without loops and stuff...
Thanks,
Alex
I need to get a string containing a specified control full location namespace...
Explaining it better, imagine this:
MyProject +-> MyForm1 +-> TabControl1 +-> TabPage1 +-> Button1
Giving the Button1 object as a parameter, I need to have a function that can retrieve me:
"MyProject.MyForm1.TabControl1.TabPage1.Button1"
My current solution looks like this:
Visual Basic:
Shared Function GetParentTreeNamespace(ByVal ctrl As Control) As String
If ctrl Is Nothing Then Return ""
Dim pForm As Form = ctrl.FindForm
Dim retval As String = ctrl.Name
Dim cCtrl As Control = ctrl
Do While Not cCtrl.Parent Is Nothing
If cCtrl.Parent Is pForm Then
retval = pForm.GetType.FullName & "." & retval
Else
retval = cCtrl.Parent.Name & "." & retval
End If
cCtrl = cCtrl.Parent
Loop
Return retval
End Function
I was hoping that there were a solution without loops and stuff...
Thanks,
Alex