目前Winforms控件一般都没办法拖动,C1这些输入控件也不支持
拖动功能目前只能是二次开发来实现,按照你这边的界面,应该是需要标签和输入框一起拖动
可以对标签设置可以拖动,将标签对应的输入框设置为标签的tag,然后可以参考下面的代码
- private Point mouseOffset;
- bool isMouseDown = false;
- private void label1_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- mouseOffset.X = e.X;
- mouseOffset.Y = e.Y;
- isMouseDown = true;
- }
- }
- private void label1_MouseMove(object sender, MouseEventArgs e)
- {
- if (isMouseDown)
- {
- label1.Location = new Point(label1.Left + e.X - mouseOffset.X, label1.Top + e.Y - mouseOffset.Y);
- var ctl = label1.Tag as Control;
- ctl.Location = new Point(ctl.Left + e.X - mouseOffset.X, ctl.Top + e.Y - mouseOffset.Y);
- }
- }
- private void label1_MouseUp(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- isMouseDown = false;
- }
- }
复制代码 |