问题描述
- C# web 鼠标拖拽的问题,运行后,报错,MouseEventArgs下有蓝波浪线,有劳达人帮忙。
-
private int tmpx = 0; private int tmpy = 0; private void panel1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.tmpx = e.X; this.tmpy = e.Y; this.panel1.Cursor = Cursors.SizeAll; this.panel1.MouseMove += new MouseEventHandler(panel1_MouseMove); } } private void panel1_MouseUp(object sender, MouseEventArgs e) { this.panel1.Cursor = Cursors.Default; this.panel1.MouseMove -= new MouseEventHandler(panel1_MouseMove); } void panel1_MouseMove(object sender, MouseEventArgs e) { this.panel1.Location = new Point(this.panel1.Location.X + e.X - this.tmpx, this.panel1.Location.Y + e.Y - this.tmpy); }
解决方案
这些代码不能用于asp.net的panel控件,它们只能用于winforms的控件。要在web程序中处理鼠标,需要用javascript。
时间: 2024-09-16 22:30:01