huangs3
asked on
C# GUI program in Visual Studio 2005: can a user control use a public variable of its parent form?
Hi Experts:
I am working on a Visual Studio 2005 C# project.
I have a user defined control, which is used by a form (note that they are in different .CS files, but in the same name space). There is DataGridView inside the user control, and I wanted to let an event handler of this DataGridView read a public variable member of the parent form. However, that variable is not recogonized in the event handler.
Does it mean that the scope of the parent form public variable does not include the event handlers of the user control?
Thank you!
I am working on a Visual Studio 2005 C# project.
I have a user defined control, which is used by a form (note that they are in different .CS files, but in the same name space). There is DataGridView inside the user control, and I wanted to let an event handler of this DataGridView read a public variable member of the parent form. However, that variable is not recogonized in the event handler.
Does it mean that the scope of the parent form public variable does not include the event handlers of the user control?
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Obviously there are other options if you change your design...
ASKER
changing the Form variable to STATIC doesn't help. I am thinking about alternative decide. Any idea?
ASKER
I found STATIC variable in the FORM works now, and trying to find other alternative.
Idle Mind already answered my question completely.
Idle Mind already answered my question completely.