I have event Button that creates text box in run time.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim textbox1 As New TextBox
static Dim shiftDown As Integer
static Dim counter As Integer
counter += 1
shiftDown = shiftDown + 30
textbox1.Name = "Textbox" + counter.ToString()
textbox1.Size = New Size(170, 10)
textbox1.Location = New Point(10, 32 + shiftDown)
textbox1.Visible = True
GroupBox1.Controls.Add(textbox1)
End Sub
All the text boxes that has been created displayed in GroupBox control dynamically.
My question is how GroupBox control size can be managed according to quantity controls inside it.
Use the
AutoSizeandAutoSizeModeproperty of groupbox.Set the
AutoSize = trueif the GroupBox need to automatically resizes based on its contents; otherwise, false. The default is true.Refer the sample to dynamically control the size of GroupBox