martialarts
Regular
My program reads from a data file and outputs a series of controls for each line in the text file. I am using .NET 2002 and from what I can gather, control collections are no longer built in. I am trying to dynamically create and dynamically name these controls. I was able to integrate this code into my program and it works partially:
'this is part of a loop and counter is incremented each time
'element is an instance of a class
Dim LabelA1 As New Label()
LabelA1.Width = 232
LabelA1.Height = 24
LabelA1.Location = New Point(16, counter * 25)
LabelA1.Text = element.name
Me.Controls.Add(LabelA1)
LabelA1.Name = "LabelA" & counter
I don't know if I'm on the right track, but it does display all the controls like I need it to when I run it. The problem is that all the labels are named "LabelA1", and my attempts to manipulate any one of them are treated aggregately. I guess this is because their name was "LabelA1" when added to me.controls. Please point me in the right direction. I am new to VB and .NET, but not to programming in general. Thanks!
'this is part of a loop and counter is incremented each time
'element is an instance of a class
Dim LabelA1 As New Label()
LabelA1.Width = 232
LabelA1.Height = 24
LabelA1.Location = New Point(16, counter * 25)
LabelA1.Text = element.name
Me.Controls.Add(LabelA1)
LabelA1.Name = "LabelA" & counter
I don't know if I'm on the right track, but it does display all the controls like I need it to when I run it. The problem is that all the labels are named "LabelA1", and my attempts to manipulate any one of them are treated aggregately. I guess this is because their name was "LabelA1" when added to me.controls. Please point me in the right direction. I am new to VB and .NET, but not to programming in general. Thanks!