Reputation: 783
I have a custom control which I add a number of to a flowlayoutpanel:
Dim drive As New WindowsControlLibrary1.UserControl1()
drive.FileSystemlable = reader.GetString(2)
drive.AbalableSpaceLable = Convert.ToInt32(reader.GetString(4) / 1024)
drive.TotalSpaceLable = Convert.ToInt32(reader.GetString(5) / 1024)
drive.SetVolumeLable = reader.GetString(3)
Dim usedspace As Integer = Convert.ToInt32(reader.GetString(5)) - Convert.ToInt32(reader.GetString(4))
drive.BarValue = usedspace / 1024
Form1.FlowLayoutPanel1.Controls.Add(drive)
How can I now update these controls instead of clearing them and re-adding them all again?
Upvotes: 1
Views: 118
Reputation: 81620
Try giving your controls unique names:
Dim drive As New WindowsControlLibrary1.UserControl1()
drive.Name = "drive1"
then you can just reference them in the panel's control collection by name:
With DirectCast(Form1.FlowLayoutPanel1.Controls("drive1"), WindowsControlLibrary1.UserControl1)
.BarValue = 50
End With
Upvotes: 3