Creating TextBoxes Dynamically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my previous posting I failed miserably, to give enough information to get
my difficulty apparent.

So to start again. I want to create textboxes dynamically in VB.NET. This
is not a web application that I'm trying to build. I should add that i am a
very new user to VB.NET and as such am very ignorant so please excuse this.

Many thanks for any assistance.

regards

Brian
 
Hi Brian,

To create any kind of object dynamically you just call its constructor.

TextBox t = new TextBox();

This will create a TextBox object and store a reference to it in 't'.

Before you can see it you also need to add it to a container object, like
a windows form

Me.Controls.Add(t)

You should now be able to see a TextBox at the default position with
default size.



To create several TextBoxes, repeat the code above.
To keep track of the various TextBoxes you can set the TextBox.Name
property, store the references in various lists etc.
 
Back
Top