PictureBox实现进入换色,离开换色,点击换色 PictureBox Picture 实现进入换色 离开换色 点击换色 Box
实现和Word标题栏类似的效果
可以看到有三种颜色:
默认时是(243, 243, 243),鼠标进入时是这样(210, 210, 210),鼠标按下的瞬间变为了(177, 177, 177)
4个关键事件:MouseEnter、MouseLeave、MouseDown、MouseUp
MouseEnter:在鼠标进入控件的可见部分时发生
private void pictureBox3_MouseEnter(object sender, EventArgs e) { pictureBox3.Image = Resources.MouseEnter; }
MouseLeave:在鼠标离开控件的可见部分时发生
private void pictureBox3_MouseLeave(object sender, EventArgs e) { pictureBox3.Image = Resources.默认状态; }
MouseDown:当鼠标指针在组件上方开按下箭标按钮时发生
private void pictureBox3_MouseDown(object sender, MouseEventArgs e) { pictureBox3.Image = Resources.点击; //MessageBox.Show("test OK!!"); }
MouseUp:在鼠标指针在组件上方开释放鼠标按钮时发生
private void pictureBox3_MouseUp(object sender, MouseEventArgs e) { pictureBox3.Image = Resources.MouseEnter; }
有朋友可能会问,为什么你要用pictureBox,而不是按钮+标签,那是因为我还想好怎么弄
panel+pictureBox+label