textboxs

spartan086

Member
Joined
Mar 23, 2011
Messages
9
Programming Experience
Beginner
so im making a program in which a user uses a scan gun to scan a bar code and the code is displayed within a textbox. The program then searchs the data base and displays the information in another 2 textboxes. All this works fine but after the information is displayed i want to create another line of textboxes. I can make the next line but my problem is how to make a generaic type code to make line after line. I initially thought of using arrays for textboxes but i guess i cant do that. What would you suggest i do?
 
You can dynamically create controls something like:

VB.NET:
Dim txt as New TextBox
'assuming me as form you want to add to
Me.Controls.Add(txt)
txt.Name = "txtName"
txt.Left = 100
txt.Top = 100

Play around with it a bit but you should be able to dynamically add and remove text boxes to forms this is a basic principle of winforms programming that made it so good if you ever had to use VB6 for any type of windows GUI it was much more difficult to do things like that. Don't forget to use refresh and doevents to make things smoother appearing to the user. Also not sure if .NET 4.0 still let's you see this but in .designer files you can see how all this happens when your form loads.
 
Back
Top