Button click

  • Thread starter Thread starter Celine
  • Start date Start date
C

Celine

This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
....
}
Thanks
Celine
 
Celine said:
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine

If I understand your question, you don't program this way any more. Instead use events. The easiest way to do this is to place a
button on the form and double click it. The function that is created will be called when someone clicks the button. Put the code you
want in there.
 
Celine said:
This question might be very trivial but how can I check that a button
is clicked. Is there a way to do something like:
if(button is clicked)
{
...
}
Thanks
Celine

Assuming you're working in Visual Studio .NET, the click event is the
default event for a Button object, and you can obtain a proper event
procedure shell by double-clicking on the button in question, in design
view.

private void button1_Click(object sender, System.EventArgs e)

{


}

Place the code you want to execute when the button is clicked in this event
procedure.

Caveat: this example is from a Windows application where the name of the
button object is button1.

Hope this helps.
 
Hi,

By default, buttons doesn't store the state information like whether the
button is clicked or not.

So declare a boolean private variable.

In the button click event, set the value for your boolean variable.

Now you can access the variable and can tell that whether the button is
clicked or not.

Regards,
R.Balaji
 
Back
Top