Solved

Buttons?

Posted on 2006-11-06
4
616 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# MVC Insert Multiple Row into DB 2 62
Please explain purpose of GZIP 4 58
Unlocking a column in excel using C# 17 27
Making exceptions for ValidationAttribute 2 25
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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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