Finding paths  
Author Message
bob laros





PostPosted: Windows Forms General, Finding paths Top

Does anybody know how to use reflections to find paths like applicationID - Form - Control - Control - Control if you only have the last control to use


Windows Forms21  
 
 
bob laros





PostPosted: Windows Forms General, Finding paths Top

I found this but don't know how to impliment it will this help

private void button1_Click(object sender, System.EventArgs e)
{
   // Get the control the Button control is located in. In this case a GroupBox.
   Control control = button1.Parent;
}

I am writing a library so I wonb't have access to the private void button1_click () function.



 
 
James Curran





PostPosted: Windows Forms General, Finding paths Top

I'm pretty sure the answer is no.

I'm a little confused as to exactly what you want, and I'm pretty sure, you're even more confused.

Reflection works on types. When you say "the last control to use" I assume you mean an instance of one particular control, (btnGo, for example), but with Reflection we only work with the type (Button), and buttons are all over the place.

Now, you are on the right track with the Parent property, but that is only defined when you actually have instaniated the control in the form in the application.

So, to fully answer your question, we'll need to know where & when & why you need to know this information.