473,671 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Labels,TextBoxe s at runtime in WEbapplication with VB.net

14 New Member
Hi,

I want to add textboxes and labels at runtime. Controls are to be added according to the value entered in textbox.
txtfamily is a textbox,in which user gives the no of familymembers.
i want to add age,gender,note s for each member.I have to repeat this process for total no of family members.
Iam trying this code below, please help me..iam not getting exactly what i wanted.


Private Sub txtfamily_TextC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtfamily.TextC hanged
Dim tb As TextBox
Dim lb1 As New Label
Dim lb2 As New Label
Dim lb3 As New Label
lb1.Text = "Age"
lb2.Text = "Gender"
lb3.Text = "notes"
placeholder1.Co ntrols.Add(lb1)
placeholder1.Co ntrols.Add(lb2)
placeholder1.Co ntrols.Add(lb3)
Dim n As Integer = Val(txtfamily.T ext)
For i As Integer = 0 To n - 1
For j As Integer = 0 To 2
tb = New TextBox
Placeholder2.Co ntrols.Add(tb)
Next
Next
End Sub
May 16 '07 #1
1 2114
dip_developer
648 Recognized Expert Contributor
Hi,

I want to add textboxes and labels at runtime. Controls are to be added according to the value entered in textbox.
txtfamily is a textbox,in which user gives the no of familymembers.
i want to add age,gender,note s for each member.I have to repeat this process for total no of family members.
Iam trying this code below, please help me..iam not getting exactly what i wanted.


Private Sub txtfamily_TextC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtfamily.TextC hanged
Dim tb As TextBox
Dim lb1 As New Label
Dim lb2 As New Label
Dim lb3 As New Label
lb1.Text = "Age"
lb2.Text = "Gender"
lb3.Text = "notes"
placeholder1.Co ntrols.Add(lb1)
placeholder1.Co ntrols.Add(lb2)
placeholder1.Co ntrols.Add(lb3)
Dim n As Integer = Val(txtfamily.T ext)
For i As Integer = 0 To n - 1
For j As Integer = 0 To 2
tb = New TextBox
Placeholder2.Co ntrols.Add(tb)
Next
Next
End Sub
now what's the problem?? are the textboxes generating...?? ? what are you getting....??? if the positioning is not OK then specify the location of newly created boxes..
May 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
464
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my asp table. The asp table has numerous rows and each row has a label item within it. Im finding it impossible to get something to work which adds the newest item in the array list to the next row in the asp table. the first time the button is...
2
1645
by: Paul Dunstone | last post by:
Hi group I am trying to add a custom attribute to all .NET elements such as textboxes, labels, datagrids etc. I want to add an attribute called 'key'. I already have the code working for the key attribute (it is used to localise text within the element) but .NET reports that the attribute is not valid. Although the code works I would prefer not to get the warning each time myself or one of the other coders use the key attribute. Is
4
1791
by: Dalan | last post by:
I have been using a module for printing labels in Access 97, and although it works fine, I would like to add a small enhancement to it. The module allows for setting the number of labels to print and/or to skip; however, the Cancel command button does not function, nor does clicking the X-close. Clicking either one is the same as clicking the OK button. Since the module creates and displays the dialog box, I will need a piece of code to...
6
2102
by: DebbieG | last post by:
I am creating a database for a small department in a university. Each student in their database can have 2 mailing addresses. They wanted mailing labels pulling just the 1st address. No problem. However, now they want a second label for students that have a second mailing address. Any ideas of how I can accomplish this? Thanks in advance for any help.
4
1937
by: slylos | last post by:
I've got a Windows form that has a TabControl. I add TabPages to this TabControl at Runtime, along with two Textboxes and a button. The problem I'm having is I can't figure out how to reference the Textboxes elsewhere once they have been created. The TextBoxes are being named based on a private global counter (i.e. TextBox tb = new TextBox(); tb.Name = "tb" + (counter++).ToString();) They are being created in a private method called...
6
1284
by: Dany P. Wu | last post by:
Hi everyone, I created a page which contains a two-column table. The first column has a bunch of labels, and the second a bunch of textboxes. Here's the code: ====================================================== Protected WithEvents Container As System.Web.UI.WebControls.PlaceHolder Private Sub ConstructEditTable() Container.Controls.Add(New LiteralControl("<table>" & vbNewLine))
2
1327
by: Peter Stojkovic | last post by:
I have some windows, which have a lot of Textboxes, labels and buttons. How can i - in a simple way- make a print out of all these textboxes ( "input" of textboxes of course ), labels and .so.on. Thanks fpr any help Peter
1
3185
by: Rohan | last post by:
Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label controls Transperent ?
11
4928
cindy2
by: cindy2 | last post by:
Hi everyone, I have 4 textboxes on form1. On runtime the user will be asked to fill in names. After that, I want these names placed RANDOMLY on 4 labels (form2). How should I do that? I am trying it for ages but I still don't have a clue to get them random. Please help me. Cindy
0
8930
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
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
2
1816
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.