New obect in a Panel

  • Thread starter Thread starter Bob Hollness
  • Start date Start date
B

Bob Hollness

Hi guys,

I have a panel on a form. I want to add (inside) this panel some textboxes.
Can any body show me with code how this would be done? Until my function
runs, I do not know how many textboxes I need.

Thanks
Bob
 
Hi

Dim i As Integer = 0
Dim y As Integer = 0

For i = 0 To 5
Dim text As New TextBox()
text.Name = "text" & CStr(i)
text.Location = New Point(10, y)
text.Text = CStr(i)
Panel1.Controls.Add(text)
y += 20
Next

hth Peter
 
In addition to peter's answer I would use a hash table, create a shared
instance of the hash table so all textboxes are available to you
throughout your application, and then add handlers based on the names
you give them in the hashtable.
 
Bob Hollness said:
I have a panel on a form. I want to add (inside) this
panel some textboxes.

\\\
Dim SampleTextBox As New TextBox()
With SampleTextBox
.Left = 100
.Top = 200
.Height = 20
.Width = 120
.Text = "Foo"
...
End With
Me.Panel1.Controls.Add(SampleTextBox)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top