473,568 Members | 2,850 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.SuspendLayou t()

TextBox1.Create Control()
TextBox1.Locati on = 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.F ont,
FontStyle.Bold)
TextBox1.Name = nName '"TextBox1"
TextBox1.Text = nName 'TextBox1.Name
Controls.Add(Te xtBox1)
Me.ResumeLayout (True)
AddEvents(TextB ox1)
End Sub

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

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

If ctrl.HasChildre n Then
AddEvents(ctrl)
End If
Next
End Sub
Nov 22 '05 #1
2 1374
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
11319
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 create Submenus and Menuitems dynamically. It is possible to create menus using array index. But if I have multiple folders and files in Favorites then...
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 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
0
1075
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 dynamically using a html-table.... i want to display dynamically on each row one button, and dont use datagrid.
2
2003
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 the number of people i want to create a form where he can enter the persons details. For example he wants to register 3 people. Then the second...
2
2901
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 avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the...
2
4554
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 easy, but 1) How do I set about dynamically creating user controls (like TextBox, TextArea) --- simply Declare and initialised (new) the user...
1
1189
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 their properties (they list CssClass, but but not a place where I can enter either a string or property/value pairs). In the past when making pages I...
6
1952
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 ViewState of the second child control gets confused with the first child control - the first Text property in the 2nd child gets updated with the...
6
6087
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 Dynamically creating a survey on a page. I have read some MS articles on dynamic creation of web forms and have been able to create one question...
5
2012
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 = rowDS.Item("Option_Item_Desc") chkCatOption.ID = rowDS.Item("ID").ToString chkCatOption.Checked = rowDS.Item("HasOption")...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2101
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 we have to send another system
0
932
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.