How to reference a control using its name?

  • Thread starter Thread starter Mattias Sjögren
  • Start date Start date
M

Mattias Sjögren

I know I could maintain an array of references but I wonder if there is some
other way?

There are many other ways, but just keeping a reference to the control
is certainly the easiest one. Not sure why you'd prefer to use
reflection instead.


Mattias
 
Suppose I create a control as follows:

Dim MyPictureBoxNew As MyPictureBox.ControlPictureBox
MyPictureBoxNew = New MyPictureBox.ControlPictureBox
MyPictureBoxNew.Name = "PictureBox" & cstr(index)

Now I want to access a method:
PictureBox22.clear
That won't work.
Is there something that will?
I know I could maintain an array of references but I wonder if there is some
other way?
Maybe using reflection which I know nothing about?


Thanks in advance
 
I don't prefer Reflection.
I was wondering if some way I didn't know was the easiest way.
Since you said the array is, I'll do it that way.

Thanks
 
Back
Top