> 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;