private void Red_TextChanged(object sender, EventArgs e)
{
int red, green, blue = 0;
if (Red.Text == string.Empty) red = 0; else red = Int32.Parse(Red.Text);
if (Green.Text == string.Empty) green = 0; else green = Int32.Parse(Green.Text);
if (Blue.Text == string.Empty) blue = 0; else blue = Int32.Parse(Blue.Text);
System.Drawing.Color fontColor= Color.FromArgb(red, green, blue);
Message.ForeColor = Color.FromArgb(red, green, blue);
System.Drawing.Color bgColor = Color.FromArgb(fontColor.ToArgb() ^ 0xffffff);
this.BackColor= bgColor;
}
private void Blue_TextChanged(object sender, EventArgs e)
{
int red, green, blue = 0;
if (Red.Text == string.Empty) red = 0; else red = Int32.Parse(Red.Text);
if (Green.Text == string.Empty) green = 0; else green = Int32.Parse(Green.Text);
if (Blue.Text == string.Empty) blue = 0; else blue = Int32.Parse(Blue.Text);
System.Drawing.Color fontColor = Color.FromArgb(red, green, blue);
Message.ForeColor = Color.FromArgb(red, green, blue);
System.Drawing.Color bgColor = Color.FromArgb(fontColor.ToArgb() ^ 0xffffff);
this.BackColor = bgColor;
}
private void Green_TextChanged(object sender, EventArgs e)
{
int red, green, blue = 0;
if (Red.Text == string.Empty) red = 0; else red = Int32.Parse(Red.Text);
if (Green.Text == string.Empty) green = 0; else green = Int32.Parse(Green.Text);
if (Blue.Text == string.Empty) blue = 0; else blue = Int32.Parse(Blue.Text);
System.Drawing.Color fontColor = Color.FromArgb(red, green, blue);
Message.ForeColor = Color.FromArgb(red, green, blue);
System.Drawing.Color bgColor = Color.FromArgb(fontColor.ToArgb() ^ 0xffffff);
this.BackColor = bgColor;
}
green,blue and red are 3 text boxes with respective names and there is a 4th text box named 'randomText' which contains some particular text whose color should change based on other 3 text boxes .
If(green.Text != "0" && blue.Text=="0" && red.Text=="0")
{
randomText.ForeColor=Color.Green; //make sure you have System.Drawing assembly reference
Form1.BackColor=Color.Red; // Form1 is your form's name
}
The problem is this:
the codes which I mentioned by red gives me errors and I don't know how to solve them.