首页 > 解决方案 > 位置限制与表格的大小

问题描述

您好我一直想知道如何使用表单的大小设置位置限制。

private Point MouseDownLocation;

private void labelControl1_MouseDown(object sender, MouseEventArgs e)
{
   if(e.Button == MouseButtons.Left)
    {
        MouseDownLocation = e.Location;
    }
}

private void labelControl1_MouseMove(object sender, MouseEventArgs e)
{ 
    if(e.Button == MouseButtons.Left)
    {
        labelControl1.Left = e.X + labelControl1.Left - MouseDownLocation.X;
        labelControl1.Top = e.Y + labelControl1.Top - MouseDownLocation.Y;
    }
}

这是我一直在使用的代码。有人可以帮忙吗。任何代码都是有用的,我只想要一些如何做的例子。

标签: c#winforms

解决方案


推荐阅读