473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Controls dynamically in visual basic.net

Hi-
I have code that dynamically adds 1 to 10 textboxes to a form. The
user is asked how many boxes he/she needs.

Problem is, I can't get to the events of each box that is added EXCEPT
for the last one.

I need to do a running total of the text boxes as the user enters a
value and moves onto the next textbox

I've tryed everything and cn't seem to get it.
I've tried Addhandler.

MY CODE
******************************

Private WithEvents TextBox1 As New TextBox

*****************************************
Public Sub FSA_SetControls(ByVal num As Int32, ByVal nName As
String, ByVal thelocation As Int32, ByVal TypeofControl As String)

TextBox1 = New TextBox
Me.SuspendLayout()

TextBox1.CreateControl()
TextBox1.Location = New Point(296, thelocation) 'left/top
TextBox1.Size = New Size(71, 23) ' width/height
TextBox1.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12)
TextBox1.Font = New System.Drawing.Font(TextBox1.Font,
FontStyle.Bold)
TextBox1.Name = nName '"TextBox1"
TextBox1.Text = nName 'TextBox1.Name
Controls.Add(TextBox1)
Me.ResumeLayout(True)
AddEvents(TextBox1)
End Sub

*****************************************

Private Sub ProcessLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.Leave
MsgBox("TESTING")
End Sub
*****************************************
Private Sub AddEvents(ByVal ctrlParent As Control)
Dim ctrl As Control
For Each ctrl In ctrlParent.Controls
If TypeOf ctrl Is TextBox Then
AddHandler ctrl.Leave, AddressOf ProcessLeave
End If

If ctrl.HasChildren Then
AddEvents(ctrl)
End If
Next
End Sub
Nov 22 '05 #1
2 1371
No problem at all, I know the feeling. I'm very glad I could help

- Nathon
Nov 22 '05 #2
No problem at all, I know the feeling. I'm very glad I could help

- Nathon
Nov 22 '05 #3

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

Similar topics

1
11309
by: Venkatesh | last post by:
Hi Everybody, This is the first timw I am entering into this Group. I am developing a VB Project with an MDI form. I want to display IE Favorites into my application. For this I need to...
2
355
by: fplisa | last post by:
Hi- I have code that dynamically adds 1 to 10 textboxes to a form. The user is asked how many boxes he/she needs. Problem is, I can't get to the events of each box that is added EXCEPT for the...
0
1071
by: tommy | last post by:
hello everybody, i haved read a few articles about, how to create controls in asp.net dynamically! i have tested it -- all works fine.... but....now it comes--> HOW create controls...
2
2000
by: DaWoE | last post by:
Hi all, I'm fairly new to ASP.NET. What i want to do is creat a online registration form. On the first step is getting the users details and the number of people he wants to register. Based on...
2
2893
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
2
4548
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
1
1182
by: Nathan Sokalski | last post by:
I have a User Control (.ascx & .ascx.vb) for which I need to dynamically specify certain CSS stylesheet properties. Because the controls that I use in the .ascx file do not list style as one of...
6
1950
by: Louise | last post by:
I use Visual Basic .NET Framework 1.1, Visual Studio. I have a Web page (aspx) referencing a control (ascx) that has a placeholder that is assigned one of 2 child controls through buttons. The...
6
6079
by: Tex | last post by:
I am writting a survey system web application. I am using ASP.Net 2, C# and MS SQL 2005. I am able to store surveys and questions associated to the surveys just fine. The problem I am having is...
5
2008
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text...
0
7198
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
7271
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
7319
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
7449
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
5570
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,...
0
4666
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
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
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
373
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.