Hello everyone,
I've a form with a groupbox witch contain 4 buttons. I searching for a
solutions to detect when I click on one of the buttons returning a reference
to the button thas has been pressed.
Thanks in advance,
Benny 5 4254
Hi Ben,
You mean something as in the click event of the button
Button1.text = "I have been clicked"
You can set for every button whatever you want or are you maybe talking bout
the toolbar?
Cor
"BenCoo" <be****@NOSPAMt elenet.be> Hello everyone,
I've a form with a groupbox witch contain 4 buttons. I searching for a solutions to detect when I click on one of the buttons returning a reference to the button thas has been pressed.
Thanks in advance,
Benny
"BenCoo" <be****@NOSPAMt elenet.be> schrieb: I've a form with a groupbox witch contain 4 buttons. I searching for a solutions to detect when I click on one of the buttons returning a reference to the button thas has been pressed.
Add a handler to the button's 'Click' event (this can be done by
doubleclicking the button in the Windows Forms designer). You can cast the
parameter 'sender' to 'Button' if you need a reference to the button that
raised the event, for example.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
The meaining of the buttons in the groupbox is to calculate a sum. Each
button has a text "10", "20", "30", and so on...In stead of use each buttons
click-event to calculate : sum += 10, sum+= 20, I want to use something
like this:
Select Case ButtonPressed
case "Button10"
sum += 10
case "Button20"
sum += 20
case "Button30"
sum += 30
End Select
"BenCoo" <be****@NOSPAMt elenet.be> schreef in bericht
news:Im******** ***********@pho bos.telenet-ops.be... Hello everyone,
I've a form with a groupbox witch contain 4 buttons. I searching for a solutions to detect when I click on one of the buttons returning a reference to the button thas has been pressed.
Thanks in advance,
Benny
"BenCoo" <be****@NOSPAMt elenet.be> wrote The meaining of the buttons in the groupbox is to calculate a sum. Each button has a text "10", "20", "30", and so on...In stead of use each buttons click-event to calculate : sum += 10, sum+= 20, I want to use something like this:
Select Case ButtonPressed case "Button10" sum += 10 case "Button20" sum += 20 case "Button30" sum += 30 End Select
You can declare one routine to handle multiple events, such as:
Private Sub ButtonClicks(By Val sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button10.Click, Button20.Click, Button30.Click
If sender Is Button10 Then
sum += 10
ElseIf sender Is Button20 Then
sum += 20
ElseIf sender Is Button30 Then
sum += 30
End If
End Sub
HTH
LFS
Thanks Larry !! You've put me on the right track !!
I use you're solution, but in the Tag-propertie of each button I place the
value (Button10.Tag = 10, Button20.Tag = 20, and so on) and then I've only
to add the next code to the eventhandler: sum += sender.Tag
Life can be simple ;-)
Again, Thanks a lot
Benny
"Larry Serflaten" <se*******@usin ternet.com> schreef in bericht
news:ef******** ******@TK2MSFTN GP10.phx.gbl... "BenCoo" <be****@NOSPAMt elenet.be> wrote The meaining of the buttons in the groupbox is to calculate a sum. Each button has a text "10", "20", "30", and so on...In stead of use each buttons click-event to calculate : sum += 10, sum+= 20, I want to use something like this:
Select Case ButtonPressed case "Button10" sum += 10 case "Button20" sum += 20 case "Button30" sum += 30 End Select
You can declare one routine to handle multiple events, such as:
Private Sub ButtonClicks(By Val sender As System.Object, _ ByVal e As System.EventArg s) _ Handles Button10.Click, Button20.Click, Button30.Click If sender Is Button10 Then sum += 10 ElseIf sender Is Button20 Then sum += 20 ElseIf sender Is Button30 Then sum += 30 End If End Sub
HTH LFS This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeyaprakash(CK) Chittu |
last post by:
Hi
I have couple of pages that maintain some stateful information and i
need to detect browser back button press and refetch the page in order
to show the current values on the fields. Is there a simple mechanims
thru JS.
Thanks
CK
|
by: Quinn |
last post by:
When users clicked a unkown mime type link such as Zip on my website, a
"Save/Open/Cancel" dialog box pops up. Is there a way to detect which button
users clicked by using ASP? actually I only what to record the "valid"
click -- when Open/Save was clicked.
Thanks ahead.
Quinn
|
by: |-|erc |
last post by:
when a user clicks back to get to my site, I want it to run a javascript
function.
can you detect when the FORWARD button is greyed out?
Herc
--
I call3d this fugly and I'm proud www.supernerd.com.au/~gray77/kath1.jpg
|
by: Bob Hynes |
last post by:
Hi All,
When a user(s) click on the 'Apply Filter' toolbar button I want to
run some code before the 'apply filter' kicks off. That code is to
check to be sure that the user has selected a value in a perticular
field and if no value was selected then display a msgbox and then
execute the 'apply filter' else just execute the 'apply filter' so, i
think my question is;
how do I detect(vba code)when a standard toolbar button is clicked in...
|
by: hy |
last post by:
Hi all,
I got the question about the radio button. How do i
detect previous checked radio button after i checked
other's radio button.
While the new radio button checked, it need to prompt out
a confirm message box, if user click on the 'cancel'
button, system will programatically check the previous
radio button instead of the latest radio button that
checked.
| |
by: Joe |
last post by:
I have a DataGrid with a templated column that displays ImageButtons. I need
to know if one of these buttons caused the postback or just another button
on the form. If one of these buttons caused the postback than I don't want
to do a DataBind otherwise I do.
I know __EVENTTARGET doesn't return this information. Is there anything else
that does?
Thanks,
Joe
|
by: Silvia |
last post by:
Hi,
I have a form with a button and when I click in this button, how I can detect the keys pressed and put this keys pressed in text property of the button.
Thanks
Silvia
|
by: eBob.com |
last post by:
I've got the basics of an XML ini file working. I.E. I can stash away
and retrieve user preferences. (Code below.) But how do I handle a
new preference? Say I have A and B. And then I invent C. The first
time the new version with C is run the XML file will not have a value
for C. How do I detect that case? Somewhere I got the impression
that I could use IsNull, but I was unable to find an example which I
could apply to my code. My...
|
by: sahaja108 |
last post by:
Hello.
I was wondering if it possible to detect a Browser Back/Forward by PHP.
I mean. I am in page A, I go to page B and then I click on the Back button and I return to A.
Does it exist a php function that detect that I have used the Back button?
Thank you very much
|
by: john ciriello |
last post by:
Hi, is there an easy way to detect when the mouse pointer enters a disabled
button? For example I have a button I can see but it is greyed out. When the
mouse moves over it I would like to be able to right click and have it
respond with a context menu. Any ideas? Thanks in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |