I do not know where the error is but I do not change the text color when I run the program.
The textbox is created at runtime.
for (int i = 0; i < listaMIX.Length; i++)
{
TextBox _textbox = new TextBox();
_textbox.Text = listaMIX[i].ToString();
_textbox.TextAlign = HorizontalAlignment.Center;
_textbox.Width = 60;
_textbox.Height = 30;
if (System.Text.RegularExpressions.Regex.IsMatch(_textbox.Text, "[S]"))
{
_textbox.BackColor = Color.Red;
_textbox.ForeColor = Color.White;
}
if (System.Text.RegularExpressions.Regex.IsMatch(_textbox.Text, "[E]"))
{
_textbox.BackColor = Color.LightBlue;
_textbox.ForeColor = Color.Blue;
}
flowLayoutPanel1.Controls.Add(_textbox);
}
Form2 form2 = new Form2(this);
form2.Controls.Add(flowLayoutPanel1);