Answered Add Comboboxes and Textboxes on Click of button

c.vaibhav

Member
Joined
May 12, 2009
Messages
22
Programming Experience
Beginner
Hi All,

I have a windows form on which there is a textbox and a command button. When user inputs an integer in the textbox and clicks on the button, the userform grows and adds that many number of comboboxes and textboxes in a panel.

Can anybody suggest how to add variable number of comboboxes and textboxes at run time.

The maximum value of that integer would be 10.

Any help is appreciated

Thanks,
Vaibhav
 
Last edited:
May I suggest you try the NumericUpDown control for numeric user input and the FlowLayoutPanel control as layout container ?
VB.NET:
Dim number As Integer = CInt(Me.NumericUpDown1.Value)
For i As Integer = 1 To number
    Dim l As New Label
    l.Text = "number " & (Me.FlowLayoutPanel1.Controls.Count + 1).ToString
    Me.FlowLayoutPanel1.Controls.Add(l)
Next
 
Back
Top