Avatar of pauledwardian
pauledwardian
 asked on

C# Check if a button is clicked

is there a legitimate way to see if a button is clicked in C#?
I have already tried if(this.button1.enable==true) but that doesn't work in my code. I have to check a couple of buttons in each IF Statement.
Please Help!

Paul
C#.NET Programming

Avatar of undefined
Last Comment
pauledwardian

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
BuggyCoder

Simple, When ever the button gets clicked its handler gets called.
For each button have a flag(boolean) in your code and set it to true when ever the button gets clicked.

private bool IsButton1,IsButton2;

private void button1_Click(object sender, System.EventArgs e)
{
    IsButton1=true;
}

private void button2_Click(object sender, System.EventArgs e)
{
    IsButton2=true;
}

Open in new window

effes

If you are going for something like a state button, you should use a CheckBox and set its Appearance to Button.
pauledwardian

ASKER
Thanks
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck