I have a user control class, when a user selects the control (or it's children) the background of the control turns blue. When the user exits, it returns to its "unselected " state. I have accomplished this with simple ENTER/LEAVE events.
I then put multiple controls into a FlowLayoutPanel and everything works just great, I can add as many controls (with a button attached to the form) as I need.
Now... I'm trying to delete controls and I need some way to flag which control was selected last -- since the user leaves the control and the LEAVE event is fired when the click the delete button -- the bg color changes and there is no way for me to tell which control was selected last so I can't tell the delete function which control it should delete.
My solution to this is to add another property to the control, a boolean, named isSelected. I set that in the control on ENTER. What I'd like to do is monitor the isSelected boolean value and when it has changed throw an event so I can handle it in my form.
I'm asking, how can I monitor a variable in a class, and when the value is changed, throw an event.
I then put multiple controls into a FlowLayoutPanel and everything works just great, I can add as many controls (with a button attached to the form) as I need.
Now... I'm trying to delete controls and I need some way to flag which control was selected last -- since the user leaves the control and the LEAVE event is fired when the click the delete button -- the bg color changes and there is no way for me to tell which control was selected last so I can't tell the delete function which control it should delete.
My solution to this is to add another property to the control, a boolean, named isSelected. I set that in the control on ENTER. What I'd like to do is monitor the isSelected boolean value and when it has changed throw an event so I can handle it in my form.
I'm asking, how can I monitor a variable in a class, and when the value is changed, throw an event.
Comment