Windows系统中处处是事件 鼠标按下 鼠标释放
事件的发起者 事件的订阅者
事件通过回调来运行,回调通过委托来实现。
常用的事件
Load 窗体加载事件
MouseClick 鼠标点击事件 MouseMove 鼠标移动事件 KeyDown 键盘按下事件 KeyUp 键盘释放事件
menuStrip菜单栏
HScrollBar 滚动条(可以通过滚动条来控制字体 颜色等)
int x = 0;
int y = 0; bool bl = false; 鼠标移动事件
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) {
if (bl == true) {
this.Location = new Point(this.Location.X + (e.X - x), this.Location.Y + (e.Y - y)); } } 鼠标按下事件
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
x = e.X; y = e.Y; bl = true;
} } 鼠标释放事件
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
x = e.X; y = e.Y; bl = } } } }
false ;