Hi Mick,
This is what I have. The controls are in fact added to the form I need
them to be. However, when I call them to be visible, they do not appear.
I added a debug.Writeline showing position, and name of the control. All
were present and accounted for.
Thank you for your help!!
For Each de As DictionaryEntry In ClassPanel.PanelIn
For Index As Integer = 0 To DirectCast(de.Value,
Panel).Controls.Count - 1
Definstance1.Controls.Add(DirectCast(de.Value,
Panel).Controls.Item(0))
Next
DirectCast(de.Value, Panel).Visible = False
Next
'making it visible
If databasepath = cd.FavoritesPath Then
DirectCast(ccombo.ComboIn.Item("combo1"), ComboBox).Size = New
System.Drawing.Size(288, 21)
DirectCast(ccombo.ComboIn.Item("combo1"), ComboBox).Location =
New System.Drawing.Point(384, 129)
DirectCast(clabel.LabelIn.Item("lbltwo"), Label).Text =
"Select Category"
DirectCast(ccombo.ComboIn.Item("combo1"), ComboBox).Visible = True
End If
Debug.writeline
lblUpdate
632 32
Customer_Software.Form2, Text:
lblMessageCenter
256 45
Customer_Software.Form2, Text:
Label1
256 0
Customer_Software.Form2, Text:
TaskPane1
0 0
Customer_Software.Form2, Text:
Label2
256 40
Customer_Software.Form2, Text:
Label19
656 0
Customer_Software.Form2, Text:
Label20
656 0
Customer_Software.Form2, Text:
combo1
384 129
Customer_Software.Form2, Text:
combo2
264 88
Customer_Software.Form2, Text:
combo3
264 88
Customer_Software.Form2, Text:
combo4
264 88
Customer_Software.Form2, Text:
TextBox1
8 144
Customer_Software.Form2, Text:
TextBox2
8 200
Customer_Software.Form2, Text:
TextBox3
8 256
Customer_Software.Form2, Text:
TextBox4
168 313
Customer_Software.Form2, Text:
TextBox5
168 369
Customer_Software.Form2, Text:
TextBox6
168 425
Customer_Software.Form2, Text:
TextBox7
8 32
Customer_Software.Form2, Text:
TextBox8
8 480
Customer_Software.Form2, Text:
TextBox9
8 528
Customer_Software.Form2, Text:
TextBox10
8 584
Customer_Software.Form2, Text:
TextBox11
8 640
Customer_Software.Form2, Text:
TextBox12
8 696
Customer_Software.Form2, Text:
TextBox13
8 752
Customer_Software.Form2, Text:
lbltwo
280 131
Customer_Software.Form2, Text:
lblthree
8 128
Customer_Software.Form2, Text:
lblfour
8 184
Customer_Software.Form2, Text:
lblfive
8 240
Customer_Software.Form2, Text:
lblsix
8 296
Customer_Software.Form2, Text:
lblseven
168 296
Customer_Software.Form2, Text:
lbleight
8 408
Customer_Software.Form2, Text:
lblnine
168 352
Customer_Software.Form2, Text:
lblten
8 352
Customer_Software.Form2, Text:
lbleleven
168 408
Customer_Software.Form2, Text:
lbltwelve
8 16
Customer_Software.Form2, Text:
lblthirteen
8 464
Customer_Software.Form2, Text:
lblfourteen
8 512
Customer_Software.Form2, Text:
lblfifteen
8 568
Customer_Software.Form2, Text:
lblsixteen
8 624
Customer_Software.Form2, Text:
lblseventeen
8 680
Customer_Software.Form2, Text:
lbleighteen
8 736
Customer_Software.Form2, Text:
"Mick Doherty"
Lets take a closer look at your loop to see what you're asking.
we'll simplify the code and then substitute for known values to make it
clearer.
We'll assume your ControlCollection has 4 controls(although judging by
you're error it has 34).
'Simplified version of your loop
For Index As Integer = 3 to 0 Step -1
ControlCollection.Remove.Item(Index)
OtherCollection.Add(ControlCollection.Item(Index))
Next
now we'll step through and see what happens.
first iteration
ControlCollection.Remove.Item(3)
'So far so good.
OtherCollection.Add(ControlCollection.Item(3))
'Whoops! What happened there? [Index out of range.]
'ControlCollection no longer contains Item(3) because
'we removed it in the previous step.
never reach next iteration
How do we fix it?
For Index As Integer = 0 To 3
OtherCollection.Add(ControlCollection.Item(0))
'note we always remove the first item, all other items will
'be reindexed so the next control will be at index 0.
Next
No need to remove the controls from the Panel since they cannot be in two
places at once so were automatically removed from the Panel before being
added to the form.