G
Guest
Is it possible to dynamically add controls (speciifcally
System.Windows.Forms.ProgressBar and System.Windows.Forms.Label) to a panel
to a form and have them display (and fucntion) at run time?
I've been trying todo this by creating arrays of progressbars and labels.
Then for each item in the root nods of a treeView that I need to track
progress on, I create a bar and label and add them to a panel. The problem is
that when I display the panel, its blank... no labels, no progress bars.
Here's a code snippet:
'pnlProgress declared above...
'x declared above...
Dim pgb(x) As System.Windows.Forms.ProgressBar
Dim lbl(x) As System.Windows.Forms.Label
Dim tn As myTreeNode
Dim i As Integer = 0
For Each tn In Me.treeView1.Nodes
'Set up progress bars
pgb(i) = New System.Windows.Forms.ProgressBar
pgb(i).Dock = DockStyle.Fill
pgb(i).Minimum = 0
pgb(i).Maximum = 100
pgb(i).Value = 50 just to test the bar
pgb(i).Visible = True
'Set up labels
lbl(i) = New System.Windows.Forms.Label
lbl(i).Text = tn.getSlideName() & " content progress"
lbl(i).Dock = DockStyle.Left
lbl(i).Visible = True
Me.pnlProgress.Controls.Add(pgb(i))
Me.pnlProgress.Controls.Add(lbl(i))
i += 1
Next
Do I have to declare all the objects as "Friend WithEvents " at the top of
the form before I begin (no longer dynamic...)
I pretty stuck on this... Is there something I'm missing? (hopefully
something simple)
Any help would be appreciated...
Charles
System.Windows.Forms.ProgressBar and System.Windows.Forms.Label) to a panel
to a form and have them display (and fucntion) at run time?
I've been trying todo this by creating arrays of progressbars and labels.
Then for each item in the root nods of a treeView that I need to track
progress on, I create a bar and label and add them to a panel. The problem is
that when I display the panel, its blank... no labels, no progress bars.
Here's a code snippet:
'pnlProgress declared above...
'x declared above...
Dim pgb(x) As System.Windows.Forms.ProgressBar
Dim lbl(x) As System.Windows.Forms.Label
Dim tn As myTreeNode
Dim i As Integer = 0
For Each tn In Me.treeView1.Nodes
'Set up progress bars
pgb(i) = New System.Windows.Forms.ProgressBar
pgb(i).Dock = DockStyle.Fill
pgb(i).Minimum = 0
pgb(i).Maximum = 100
pgb(i).Value = 50 just to test the bar
pgb(i).Visible = True
'Set up labels
lbl(i) = New System.Windows.Forms.Label
lbl(i).Text = tn.getSlideName() & " content progress"
lbl(i).Dock = DockStyle.Left
lbl(i).Visible = True
Me.pnlProgress.Controls.Add(pgb(i))
Me.pnlProgress.Controls.Add(lbl(i))
i += 1
Next
Do I have to declare all the objects as "Friend WithEvents " at the top of
the form before I begin (no longer dynamic...)
I pretty stuck on this... Is there something I'm missing? (hopefully
something simple)
Any help would be appreciated...
Charles