Link to home
Start Free TrialLog in
Avatar of fylix0000
fylix0000

asked on

Access Object sender 's properties or object on an event.

Hi all,

I have a close window A event that get executed in window B as follow:

    void window_AClosed(object sender, FormClosedEventArgs e)
    {
    }

When I run this event in debug mode, i can see the object sender has an item from window A that  I like to use in window B.  So I looked at the expression of that object and I got the following:

 ((CAD_APP.CADScreens.frmCmdLog)(sender)).CmdLogFileDict

So after including the namespace and such I thought it will be easy as doing the following:

    void window_AClosed(object sender, FormClosedEventArgs e)
    {
       
      string n= ((CAD_APP.CADScreens.frmCmdLog)(sender)).CmdLogFileDict
    }


However, I keep getting syntax error because my sender object does not recognize that during compilation.  I am new to C# so after reading around I see the concept of "reflection" so my question is how can I access CmdLogFileDict, do I need to do something else or am I heading into the right direction by looking up on reflection?

Thank you,

ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

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
Avatar of fylix0000
fylix0000

ASKER

My college prof will be in regret mode for giving me passing grade if he knows this.  This is is my stupidities, I happened to declare CmdLogFileDict private >.<, changing it to public and it is all good.

Thanks p_davis for trying to assist me.
not a problem - glad you figured it out.