Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I cast a string into an Object
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00832051
Message ID:
00832874
Vues:
20
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform