winform,textbox控件如何取消拖放事件啊?
1、在一个类中我定义了鼠标按下,拖放,弹起事件,实现了对文本控件的拉伸和移动,当我想点“锁定”这个按钮的时候取消按下,拖放,弹起事件都失效,怎么弄呢?
2、鼠标按下,拖放,弹起事件代码如下:
private ActiveControlContainer(Control moveControl)
{
//
// TODO: 在此处添加构造函数逻辑
//
_MControl = moveControl;
_MControl.MouseDown += new MouseEventHandler(this.Control_MouseDown);
_MControl.MouseUp += new MouseEventHandler(this.Control_MouseUp);
_MControl.MouseMove += new MouseEventHandler(this.Control_MouseMove);
_MControl.Click += new System.EventHandler(this.Control_Click);
}
#region 需拖动控件鼠标事件
private void Control_Click(object sender, System.EventArgs e)
{
_textbox.Focus();
_MControl = (sender as Control);
MoveHandles();
if (_IsCtrlKey == false)
{
for (int i = 0; i < _MControl.Parent.Controls.Count; i++)
{
if (_MControl.Parent.Controls[i].Text.Trim().Length == 0 && _MControl.Parent.Controls[i] is Label)
{
_MControl.Parent.Controls[i].Visible = false;
}
}
}
}
------解决方案--------------------refer:
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.MouseDown += new MouseEventHandler(textBox1_MouseDown);
this.textBox1.MouseMove += new MouseEventHandler(textBox1_MouseMove);
}
private void textBox1_MouseMove(object sender, System.EventArgs e)
{
MessageBox.Show("mousemove...");
}
private void textBox1_MouseDown(object sender, System.EventArgs e)
{