利用GroupBox控件提示当前位置
第一步:创建一个Windows窗体应用程序项目GroupBoxTip。其窗体设计如下:
第二步:添加groupBox进入和离开事件,进入时改变背景色,离开时恢复原来颜色
private Color originalColor; //原来的背景色
//加载时得到背景色
private void Form1_Load(object sender, EventArgs e)
{
originalColor = groupBox1.BackColor;
}
private void groupBox1_Enter(object sender, EventArgs e)
{
groupBox1.BackColor = Color.LightBlue;
}
private void groupBox2_Enter(object sender, EventArgs e)
{
groupBox2.BackColor = Color.LightGreen;
}
private void groupBox2_Leave(object sender, EventArgs e)
{
goupBox2.BackColor = originalColor;
}
private void groupBox3_Enter(object sender, EventArgs e)
{
groupBox3.BackColor = Color.LightPink;
}
private void groupBox3_Leave(object sender, EventArgs e)
{
groupBox3.BackColor = originalColor;
}
private void groupBox4_Enter(object sender, EventArgs e)
{
groupBox4.BackColor = Color.LightYellow;
}
private void groupBox4_Leave(object sender, EventArgs e)
{
groupBox4.BackColor = originalColor;
}
|
|