Windows Develop Bookmark and Share   
 index > Windows Forms General > C# winform - check if event fired while in another event
 

C# winform - check if event fired while in another event

Upon firing an event (button1_Click), I want to check if another button event has been fired first before determining what to execute in this button1_Click event.

How do I check to see if a button's click event has been fired?
I've tried true or null, but these don't work.

Thanks for your help.
MigrationUser 1  Monday, April 26, 2004 4:42 PM
In your form, declare a boolean variable(say 'boolTest') and set its value to False.

In the Click event for Button2, set boolTest to True.

In the Click event for Button1, check the state of boolTest and execute code accordingly.
Then I assume you would want to reset boolTest to False at the end of Button1_Click.

I don't know enough C# to give you the exact code.

Tony
MigrationUser 1  Monday, April 26, 2004 7:51 PM
Looks to me like simply adding a private variable to the form common to both buttons, when OtherButton Clicks that variable gets set (by the handler), to whatever value the button1_ClickHandler can check.
MigrationUser 1  Tuesday, April 27, 2004 1:28 AM
Excellent.  Thank you both for the information.  I had put the private variable in as a temporary fix, but thought there would be a better way.
Thanks.  I have my problem solved!!!!
MigrationUser 1  Tuesday, April 27, 2004 9:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Different images for different Treeview nodes
• Printing Tiff images to PRN files
• Using webbrowser to display word, excel documents
• Instance of MessageBox Class in c#!
• DataBase
• Web Page on Windows Form? _Edited
• about combobox
• How to receive mouse hover events from objects in multipe MDI child windows?
• Why ComboBox.SelectedValue does not work before ParentChanged event?
• Text rendering: Designer vs. Application