RE: VB .NET dynamic number of controls...
- From: "hzgt9b@xxxxxxxxxx" <hzgt9bnopostcom@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 25 Aug 2005 06:08:05 -0700
Ok, so now that I know its possible - other than the erronous Dock values
below (just assume they are all docked to the top) - why isn't the code below
working for me? I modeled it after what the form designer created!
"hzgt9b@xxxxxxxxxx" wrote:
> 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
.
- Follow-Ups:
- Re: VB .NET dynamic number of controls...
- From: Cor Ligthert [MVP]
- Re: VB .NET dynamic number of controls...
- References:
- VB .NET dynamic number of controls...
- From: hzgt9b@nopost.com
- VB .NET dynamic number of controls...
- Prev by Date: VB.NET: DirectoryServices Member.Count limit of 1000
- Next by Date: Re: Dynamically creating a Word document
- Previous by thread: Re: VB .NET dynamic number of controls...
- Next by thread: Re: VB .NET dynamic number of controls...
- Index(es):
Relevant Pages
|