Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question
Message
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01471507
Message ID:
01471510
Views:
63
>>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;
What about assignment of array's value?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform