Ok super simple code and I hope an easy question to answer
I have a FLowLayoutPanel and in it generating a few GroupBoxes and in them a few labels.
Works dandy by itself when called from say a Form1_Load
But when I load the TestBox() sub from a timer, it keeps loading the same x groupboxes over and over
what am I missing?
FlowLayoutPanel1.Controls.Remove(gbNew) either doesn't do squat or completely blanks the panel depending on where I put it, so that isn't a solution.
I don't seem to have the issue when I do the loop without a FlowLayoutPanel so it seems something inherent to that control
Code is below
Any assistance, long as it's VB and not another language I know even less, would be greatly appreciated.Code:Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Timer1.Start() End Sub Private Sub TestBox() Dim gbCount As Integer = 5 Dim I As Integer For I = 0 To gbCount Dim gbNew As New GroupBox() Dim wlbNew As New Label() 'FlowLayoutPanel1.Controls.Remove(gbNew) ' doesn't do squat here and totally blanks before next FlowLayoutPanel1.Controls.Add(gbNew) gbNew.Controls.Add(wlbNew) wlbNew.Text = "Boogers" wlbNew.Visible = True wlbNew.Location = New System.Drawing.Point(230, 34) wlbNew.Font = New Font(wlbNew.Font.FontFamily, 6.5) wlbNew.BackColor = Color.Transparent gbNew.Size = New System.Drawing.Size(270, 80) 'gbNew.BackColor = System.Drawing.Color.Silver gbNew.Visible = True gbNew.Text = "Tis ME" & " " & I Next End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick TestBox() End Sub End Class
TIA





Reply With Quote
