473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling Events for Dynamically Created Controls

I have several Button controls that I created dynamically that I need to
handle the Click events for. How do I specify the event handler for
dynamically created controls? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 21 '05 #1
2 1982
"Nathan Sokalski" <nj********@hotmail.com> schrieb
I have several Button controls that I created dynamically that I need
to
handle the Click events for. How do I specify the event handler for
dynamically created controls? Thanks.


Use the Addhandler statement.

Armin

Nov 21 '05 #2
"Nathan Sokalski" <nj********@hotmail.com> schrieb:
I have several Button controls that I created dynamically that I need to
handle the Click events for. How do I specify the event handler for
dynamically created controls?


\\\
Private Sub Test()
Dim Button1 As New Button()
With Button1
.Location = New System.Drawing.Point(56, 88)
.Name = "Button1"
.Size = New System.Drawing.Size(144, 48)
.TabIndex = 0
.Text = "Button1"
End With
AddHandler Button1.Click, AddressOf Me.Button_Click
Me.Controls.Add(Button1)
End Sub

Private Sub Button_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox("Hello World")
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2545
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
0
1622
by: luca | last post by:
Hi all. My problem is that I can't handle events raised from child components within a composite server control when the control is created dynamically. Everything works fine if the same control...
6
1789
by: Steve Caliendo | last post by:
Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of course), but how do I...
2
1519
by: Nathan Sokalski | last post by:
I have several Button controls that I created dynamically that I need to handle the Click events for. How do I specify the event handler for dynamically created controls? Thanks. -- Nathan...
12
2764
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
9
2315
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
1
1020
by: krishna | last post by:
Hi, Hi, I would like to handle the events for the dynamically created controls at runtime. I Have written the code in HTML View of an asp.net page.like this
3
8511
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at...
5
6743
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
2
1637
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create...
0
7220
marktang
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,...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7371
jinu1996
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...
0
7479
tracyyun
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...
0
5617
agi2029
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,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
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...
0
1534
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 ...
0
410
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.