【发布时间】:2015-08-07 03:23:05
【问题描述】:
我有一个允许用户在面板中拖动文本框的 winforms 应用程序。
单击时,我设置了一个布尔标志“moveMode”,然后我将位置设置为鼠标拖动时的位置。
我认为可能是重绘速度不够快,无法拖动?有没有办法提高重绘率?
这是我的文本框 mouseMove 事件代码:
void textBox1_mouseMove(object sender, MouseEventArgs e)
{
if (draggingTxtBox && moveMode)
{
Point newLocation = new Point();
newLocation.X = e.Location.X - dragOffset.X;
newLocation.Y = e.Location.Y - dragOffset.Y;
txtBox.Location = newLocation;
dragOffset = e.Location;
dragOffset.X -= txtBox.Location.X;
dragOffset.Y -= txtBox.Location.Y;
txtBox.SelectionLength = 0;
this.Refresh();
txtBox.Refresh();
}
Point newPos = new Point();
newPos.X = e.X + offset.X;
newPos.Y = e.Y + offset.Y;}
【问题讨论】:
-
请检查此link 可能会有所帮助。