Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I cast a string into an Object
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00832051
Message ID:
00832874
Views:
18
HI Rick.

Do you know if it is working using Windows forms too?

I actually found a workaround that uses the Controls collection but I need to loop through the collection!


>Eric,
>
>Youc an use Reflection...
>
>
>Label x = (Label)
>WebForm.GetType().GetProperty("Label" + Convert.ToString(i)).GetValue(WebForm,null);
>
>MessageBox.Show(x.Text);
>
>
>Actually, you'll likely have to use GetField() instead of GetProperty()... Also, I'm not sure, but I think you need to make sure that the scope is at least Protected not private or Reflection won't be able to find it...
>
>+++ Rick ---
>
>
>>I want to cast
>>
>>"label" + Convert.ToString(i)
>>
>>into a System.Windows.Forms.Label so that I can use
>>
>>MessageBox.Show(x.Text);
>>
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform