There are two pictureboxes with two different images.
If I click on one picture box, the image in it should be cleared.
To make the matters worse, both of the picture boxes have only one common event handler. How can I know which picturebox generated the event? I would appreciate source code in C++-CLI
I need to know what to write inside the function:
private: System::Void sqaure_Click(System::Object^ sender, System::EventArgs^ e) { }
EDIT: The problem is that when I try to cast sender to picurebox, it gives an error saying that the types cannot be converted.
How are you doing the cast? In most cases like this I would use:
(Note that I’ve corrected the above code after Josh pointed out my reference flaw. Thanks!)
the dynamic cast will give you the right object type if it can cast, or null if it cant (it’s the equiv. of ‘as’ in C#)
If this does give you a null reference, then perhaps your sender is not what you think it is?