AlexCode Posted September 4, 2005 Posted September 4, 2005 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: 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 :p Quote Software bugs are impossible to detect by anybody except the end user.
Leaders snarfblam Posted September 4, 2005 Leaders Posted September 4, 2005 Considering the nature of the task, I can't see how this can be done without loops. I think that your method is as straightforward as possible. Quote [sIGPIC]e[/sIGPIC]
AlexCode Posted September 4, 2005 Author Posted September 4, 2005 Thanks... You know... hope is the last one to die... ehehehehe Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.