RE: VB .NET dynamic number of controls...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: VB .NET dynamic number of controls...
    ... Forget WithEvents. ... > I've been trying todo this by creating arrays of progressbars and labels. ... > progress on, I create a bar and label and add them to a panel. ...
    (microsoft.public.dotnet.general)
  • VB .NET dynamic number of controls...
    ... System.Windows.Forms.ProgressBar and System.Windows.Forms.Label) to a panel ... I've been trying todo this by creating arrays of progressbars and labels. ... progress on, I create a bar and label and add them to a panel. ... that when I display the panel, ...
    (microsoft.public.dotnet.general)
  • Re: Dynamic Controls - Still!
    ... I've got another page where the same code works just fine, but the labels ... A panel derives from Control just like the Page ... > Dim ddl As DropDownList = New DropDownList ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: The Electricians Credo, part XXXIV
    ... owns the house know which breaker goes where. ... The NEC requires the panel to be labeled, ... Typically you'll get general labels like first floor lighting, ... The electrician that wired my house made a computer printed label that ...
    (alt.home.repair)
  • Re: performance
    ... >I'm going to create a web form to show some textboxes to users, ... I'm thinking not using 2 pages but use panel ... >server control to group my textboxes and labels, before postback, i ... My questions is hiding a lot of server controls will be ...
    (microsoft.public.dotnet.framework.aspnet)