add button is correctly work But reset button Not Work (Always Keep one Panel)
Public Class Form1
Private Sub clear(ByVal i As Control)
Dim frmControl As Control
For Each frmControl In i.Controls
If TypeOf frmControl Is Panel Then
frmControl.Dispose()
End If
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
Static wc As SByte = 1
Dim P As New Panel
P.Name = "Panel" & WC.ToString
P.Size = New System.Drawing.Size(144, 51)
FlowLayoutPanel1.Controls.Add(P)
Dim tb As New TextBox
tb.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
tb.Name = "TextBox" & WC.ToString
tb.Dock = DockStyle.Top
tb.AutoSize = True
P.Controls.Add(tb)
tb.Focus()
Dim b1 As New Button
b1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
b1.Name = "ButtonPlay" & WC.ToString
b1.Size = New System.Drawing.Size(75, 23)
b1.Location = New System.Drawing.Point(70, 23)
b1.Text = "پخش"
Me.AddButton.UseVisualStyleBackColor = True
P.Controls.Add(b1)
Dim b2 As New Button
b2.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
b2.Name = "ButtonDelete" & WC.ToString
b2.Size = New System.Drawing.Size(40, 23)
b2.Location = New System.Drawing.Point(30, 23)
b2.Text = "حذف"
Me.AddButton.UseVisualStyleBackColor = True
P.Controls.Add(b2)
Dim b3 As New Button
b3.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
b3.Name = "ButtonInsert" & WC.ToString
b3.Size = New System.Drawing.Size(30, 23)
b3.Location = New System.Drawing.Point(0, 23)
b3.Text = "+"
Me.AddButton.UseVisualStyleBackColor = True
P.Controls.Add(b3)
wc += 1
AddButton.SendToBack()
Button2c.SendToBack()
End Sub
Private Sub Button2c_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2c.Click
clear(FlowLayoutPanel1)
End Sub
End Class