Dynamically name a object?

  • Thread starter Thread starter -BA-
  • Start date Start date
B

-BA-

Hi!

I wonder if it is possible to dynamically name a object (e.g. checkbox,
combox etc.) during runtime.

I know I can create a object during runtime like this:

Me.MyLabel = New Label
Me.Controls.Add(Me.MyLabel)
MyLabel.Text = "This is a label created during runtime."

but I would need to create the objects from a xml file and before reading
the file I have no information how many or what kind of objects (standard
windows framework) are needed.

If it is not possible to dynamically name a object during creation, is there
some other way doing this?

Thanks,
-BA-
 
Hi,

Maybe this will help.
http://windowsforms.net/articles/wfml.aspx


Ken
----------------------
Hi!

I wonder if it is possible to dynamically name a object (e.g. checkbox,
combox etc.) during runtime.

I know I can create a object during runtime like this:

Me.MyLabel = New Label
Me.Controls.Add(Me.MyLabel)
MyLabel.Text = "This is a label created during runtime."

but I would need to create the objects from a xml file and before reading
the file I have no information how many or what kind of objects (standard
windows framework) are needed.

If it is not possible to dynamically name a object during creation, is there
some other way doing this?

Thanks,
-BA-
 
-BA- said:
I know I can create a object during runtime like this:

Me.MyLabel = New Label
Me.Controls.Add(Me.MyLabel)
MyLabel.Text = "This is a label created during runtime."

but I would need to create the objects from a xml file and before reading
the file I have no information how many or what kind of objects (standard
windows framework) are needed.

If it is not possible to dynamically name a object during creation, is
there some other way doing this

What you cannot do is creating a member variable with the name of the
control at runtime. However, you can store (name, control) pairs in a
'Hashtable', for example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top