Link to home
Start Free TrialLog in
Avatar of huangs3
huangs3Flag for Canada

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!
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Obviously there are other options if you change your design...
Avatar of huangs3

ASKER

changing the Form variable to STATIC doesn't help. I am thinking about alternative decide. Any idea?
Avatar of huangs3

ASKER

I found STATIC variable in the FORM works now, and trying to find other alternative.
Idle Mind already answered my question completely.