Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie question
Message
De
06/07/2010 09:26:02
 
 
À
06/07/2010 08:55:32
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01471507
Message ID:
01471509
Vues:
79
>Here's a newbie C#
>
>I could write the code below in a few lines in VFP
>
>This isn't so bad but now now I have a similar situation with 52 values
>
>What's the best way to do this in VS 2008? (not VS 2010)
>
>
>
> switch (column)
>        {
>        case 0:
>          textBoxColumn1.Text = stack[column, row].ToString();
>          textBoxColumn1.ForeColor = textboxforecolor; 
>          break;
>        case 1: 
>           textBoxColumn2.Text = stack[column, row].ToString();
>           textBoxColumn2.ForeColor = textboxforecolor; 
>          break;
>        case 2:
>          textBoxColumn3.Text = stack[column, row].ToString();
>          textBoxColumn3.ForeColor = textboxforecolor; 
>           break;
>        case 3:
>          textBoxColumn4.Text = stack[column, row].ToString();
>          textBoxColumn4.ForeColor = textboxforecolor; 
>   
>          break;
>        case 4:
>          textBoxColumn5.Text = stack[column, row].ToString();
>          textBoxColumn5.ForeColor = textboxforecolor; 
>   
>          break;
>        case 5:
>          textBoxColumn6.Text = stack[column, row].ToString();
>          textBoxColumn6.ForeColor = textboxforecolor; 
>          break;
>        case 6:
>          textBoxColumn7.Text = stack[column, row].ToString();
>          textBoxColumn7.ForeColor = textboxforecolor; 
>         break; 
>        } 
>     
>
Assuming the textBoxColumnX items are textboxes (and that they exist):
string s = "textBoxColumn" + column.ToString();
((TextBox)this.Controls.Find(s, true)[0]).ForeColor = textboxforecolor;
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform