473,382 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Button click

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
Nov 16 '05 #1
6 23514
Celine,

why button click event handler cannot do this for you?

HTH
Alex

"Celine" <sq*****@yahoo.fr> wrote in message
news:f3*************************@posting.google.co m...
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

Nov 16 '05 #2
"Celine" <sq*****@yahoo.fr> wrote in message news:f3*************************@posting.google.co m...
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.

--
Michael Culley

Nov 16 '05 #3

"Celine" <sq*****@yahoo.fr> wrote in message
news:f3*************************@posting.google.co m...
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.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #4
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

"Celine" <sq*****@yahoo.fr> wrote in message
news:f3*************************@posting.google.co m...
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

Nov 16 '05 #5
Further to Peter's Explanation I have a very simple event driven app here,
that shows the code.
http://www.publicjoe.f9.co.uk/csharp/csharp10.html

Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html

"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...

"Celine" <sq*****@yahoo.fr> wrote in message
news:f3*************************@posting.google.co m...
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.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 16 '05 #6
Thank you all for your answers, it really helped
Celine

"R.Balaji" <rb********@hotmail.com> wrote in message news:<OM*************@TK2MSFTNGP11.phx.gbl>...
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

"Celine" <sq*****@yahoo.fr> wrote in message
news:f3*************************@posting.google.co m...
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

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
7
by: code100579 | last post by:
Hi there, sorry if this is a really simple question. I need to write code for: If a button is pushed and then one variety of other buttons is pushed then certain options on the program will...
2
by: dunderhead | last post by:
Hello, I am having a problem with function and class syntax. I have one class (MakePanel1) that creates a button and label. The button-click event of the button is linked to a function...
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.