Solved

Buttons?

Posted on 2006-11-06
4
602 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
  • 3
4 Comments
 
LVL 15

Expert Comment

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

Accepted Solution

by:
Raynard7 earned 250 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
What does this  TN Map<T, TN>(T src) mean? 5 32
Exception in Log4Net 1 20
Iterate two lists and remove inactive 11 38
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now