0
在My LocationChanged事件中,我想在更靠近屏幕边框时更改宽度/高度。将窗体拖到屏幕边框以更改其高度/宽度
我目前使用下面的代码:
private void Form1_LocationChanged(object sender, EventArgs e)
{
int BORDER_SIZE = 100;
Rectangle border = new Rectangle(
BORDER_SIZE,
BORDER_SIZE,
Screen.PrimaryScreen.Bounds.Width - BORDER_SIZE,
Screen.PrimaryScreen.Bounds.Height - BORDER_SIZE);
if(!border.Contains(Cursor.Position))
{
this.Height = 400;
this.Width = 50;
radPanel1.Height = 400;
radPanel1.Width = 50;
this.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
radMenu1.Orientation = System.Windows.Forms.Orientation.Vertical;
}
当我拖我的表格有问题的边界(保持我的点击按下)这是工作,我看到我的高度和宽度改变,但是当我释放我的鼠标,宽度和高度将恢复为其默认值。 我不明白为什么。 此外,锚不起作用。
我在想什么? 在此先感谢 它让我疯狂
可能重复[如何使我的Windows窗体应用程序捕捉到屏幕边缘?](http://stackoverflow.com/questions/589268 /如何对做 - 我的窗口形式-APP-锁定到屏幕边缘) – 2012-02-16 18:51:37