Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I am doing a c# application where I have two buttons when I am clicking button2 i want to check if the button 1 already clicked or not . How I can do that ?

What I have tried:

I search for a way to do that but i did not find any thing.
Posted
Updated 28-Nov-17 22:22pm

1 solution

Create a variable and set value false.
private bool button1Clicked = false;

On button1 Click event set value to true.
private void button1_Click(object sender, EventArgs e)
{
    button1Clicked = true;
}

Now If button1Clicked is true means button1 clicked else no.
private void button2_Click(object sender, EventArgs e)
{
    if (button1Clicked)
    { 
       // Button Clicked.. Perform Action 
    }
   else
   {
     // Button Not Clicked.. Perform Action 
   }
}
 
Share this answer
 
v2
Comments
Member 15497447 3-May-23 4:52am    
Satyajeet Deshmukh:Its working fine thanks for the solution(winforms)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900