How do I reference a control added at runtime using coordinates

lele2008

New member
Joined
Apr 1, 2008
Messages
4
Location
Zimbabwe
Programming Experience
Beginner
I've got a number of controls (labels) that i added at runtime to a windows form. Clicking on one of them saves its position ( x and y coordinates) onto a stack which is then saved in a text file. This text file can be accessed later to repopulate the stack and show which labels are being referenced from the stack by disabling them on the form but how do i do it?

My code for repopulating the stack with coordinates is:

Dim sr As StreamReader
Dim logPath As String = (pathName)
Dim locStack As New Stack

For i = 1 To locStack.Count
sr = File.OpenText(logPath)
sr.ReadLine()
sr.Close()
Next
 
Why not save the name of the control?
 
I've got multiple controls of the same type and saving the name of the control will reference about 5 different controls therefore referencing by their position on the form
 
I wasn't talking about the name of the control class, but name of the controls as in Name property of each instance. You should give your controls unique names. When you add controls from toolbox the IDE name them f.ex "Button1", "Button2" etc.
 
Back
Top