Cast a string to a Label

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Hello all,

is it possible to cast a string to a Label?

I have a Label by the name of lblStatus, a string varible
called status that I set to be = "lblStatus".

I then want to be able to do something like (example):

Label l;
l = (Label)status;
l.text = "Open".

This would then set the text of Label lblStatus = "Open".

The reason I'm doing this is beacuse I have multiple
Labels on a form and am passing a string into a method
that represents the Label that needs to be updated (it's a
string becasue it's coming from a Hashtable value, ie
myHash[Key]).

Hope there's help!

Thanks,

Jon
 
* "Jon said:
is it possible to cast a string to a Label?

No. You can store (name, control) pairs in a 'Hashtable' (name is key)
in order to access the control by its name.
 
Back
Top