Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get the TextBox object reference by using the name of th
Message
De
21/09/2003 19:07:17
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00830947
Message ID:
00830952
Vues:
19
Ali,

Well, the first thing that pops into my mind is to loop through the Controls collection until you find it. I'm not sure if that's the most efficient way (I'm currently not on my .NET computer to look for other ways).
foreach (Control o in oForm)
{
   if (o is TextBox && o.Name == sObjectName)
   {
      TextBox oTextBox = (TextBox)o;
      // more code or break or return
   }
}
~~Bonnie



>I want to get the TextBox object reference by using the name of this object.
>I can reach to this object referance, by putting ".." operator between Forms reference and name of the control (oForm..sObjectName) in Visual Foxpro.
>How can I do this in C#
>
>public static string GetObjectFromStr(Form oForm, string sObjectName) // sObjectName = "txtCompanyName"
>{
> // How can I get oTextBox
> TextBox oTextBox = (TextBox) oForm..sObjectName;
>}
>
>Thank in advance
>
>Ali Altun
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform