| | |
click events for rutime generated controls
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
1
#11 18 Days Ago
•
•
•
•
What values do you need to pass? Unless you right a custom event handler, the click event has a defined argument list.
You can check which button was clicked inside the event handler by converting Sender back to a button:
C# Syntax (Toggle Plain Text)
Button btnClicked = (Button)sender; if(btnClicked.Name=="Button1") //do something
Alternaively, if each button has different behaviour then give each one a different handler:
C# Syntax (Toggle Plain Text)
private void Form1_Load(object sender, EventArgs e) { Button b1 = new Button(); b1.Click += new EventHandler(b1_Click); Button b2 = new Button(); b2.Click += new EventHandler(b2_Click); } void b1_Click(object sender, EventArgs e) { // put your code } void b2_Click(object sender, EventArgs e) { // put your code }
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
0
#12 17 Days Ago
bk_bhupendra,
Please stop using [quote][/quote] quotes for all of your posts. That is intended for quoting other people when you want to reply to their post. Just post your responses in the normal whitespace of the reply box. Use [code][/code] when posting code.
Please stop using [quote][/quote] quotes for all of your posts. That is intended for quoting other people when you want to reply to their post. Just post your responses in the normal whitespace of the reply box. Use [code][/code] when posting code.
![]() |
Similar Threads
- Handler attached to Button.Click inside Gridview not firing (ASP.NET)
- Handing OnChange and OnEnter events for forms with many controls (Pascal and Delphi)
- Button Click for dynamic controls (ASP)
- Handling Browser Click Events (VB.NET)
- hangman revised (VB.NET)
- Controls on form disappears when auto-generated controls code modified (C++)
- Big Problem, Generic Error (VB.NET)
Other Threads in the C# Forum
- Previous Thread: SMS Sender in C#.NET
- Next Thread: using INI(setting) file in c#
| Thread Tools | Search this Thread |
.net access algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client clock combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing dynamiccreation encryption enum excel file form format forms function gdi+ hospitalmanagementinformationsystem hospitalmanagementsystems image index input install interface java label list listbox mandelbrot math microsystems mouseclick mysql operator password path photoshop picturebox pixelinversion post priviallages. programming property radians regex remoting richtextbox running... serialization server sleep soap socket sql sqlserver stack statistics stream string table temperature text textbox thread time timer update usercontrol validation visualstudio webbrowser windows windowsformsapplication winforms wpf write xml






