C# Winform 更改选中文字的颜色代码如下:
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.Items.Add("蓝色");
this.comboBox1.Items.Add("红色");
this.comboBox1.Items.Add("黄色");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "蓝色")
{
this.label1.BackColor = Color.Blue;
}
if (comboBox1.Text == "红色")
{
this.label1.BackColor = Color.Red;
}
if (comboBox1.Text == "黄色")
{
this.label1.BackColor = Color.Yellow;
}
}
温馨提示:答案为网友推荐,仅供参考