?
Solved

Buttons?

Posted on 2006-11-06
4
Medium Priority
?
641 Views
Last Modified: 2008-02-01
You want to accomplish the following with a Button Control:

1.) Add the Button
2.) Add the Event Handler
3.) Trigger the event

Which would be the correct segment of code to accomplish these tasks?
Button b = new Button(new EventHandler(onButtonAction));
b.clicked = True;
 
 
--------------------------------------------------------------------------------
 
  Button b = new Button(new EventHandler(onButtonAction));
b.clicked(1);
 
 
--------------------------------------------------------------------------------
 
  Button b = new Button();
b.ButtonClick += new ButtonEventHandler(onButtonAction);
b.clicked(1);
 
 
--------------------------------------------------------------------------------
 
  Button b = new Button();
b.ButtonClick += new ButtonEventHandler(onButtonAction);
b.clicked = True;
 
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17885773
None of the above.
0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 1000 total points
ID: 17885778
Below would be the correct method to add a button handler

Button b = new Button();
b.ButtonClick += new ButtonEventHandler(onButtonAction);

To trigger the event you should just be able to call the routine you delegated to button above, rather than setting a property of the button itself.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17885795
Button does not have any contsructor that takes an argument, nor does it have any property, method or event called ButtonClick or clicked;
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17885805
Ah, unless this is some fantasy Button control you have written yourself in which case it could be either of the last two options depending on how you had written the control.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question