I think I could use Type.GetProperties if I could first get a
reference to the containg form.
The UserControl exists as a .DLL that I include in new form
development projects with "MyControl myControl = new MyControl()" and
it appears on the form at run-time.
My problem is that I have to now redesign the user control to read
from an ArrayList that exists on the form that contains the control.
At design time the control has no connection to the form, and creating
a "new" form will not work because the control needs to access the
existing/containing form.
I have played a little bit more. Here is non-working code, maybe this
will illustrate what I am trying to do:
Form parentForm = this.FindForm(); // returns null
IContainer parentContainer = this.Site.Container; //
NullReferenceException
ComponentCollection parentCollection = parentContainer.Components;
for( int pcC=0 ; pcC < parentCollection.Count ; pcC++ )
{
if ( parentCollection[pcC].GetType() == typeof(Form) )
{
int fhf=pcC;
int fjfj=4; // breakpoint set but I never get here
}
}
Help!
Thanks.
I would choose another approach: Provide an interface that the form must
implement, then you don't need reflection to access the member.