C# 将窗体拖动到屏幕边框以更改其高度/宽度
在我的LocationChanged事件中,我希望在靠近屏幕边框时更改宽度/高度 我目前正在使用以下代码:C# 将窗体拖动到屏幕边框以更改其高度/宽度,c#,.net,anchor,dock,C#,.net,Anchor,Dock,在我的LocationChanged事件中,我希望在靠近屏幕边框时更改宽度/高度 我目前正在使用以下代码: private void Form1_LocationChanged(object sender, EventArgs e) { int BORDER_SIZE = 100; Rectangle border = new Rectangle( BORDER_SIZE, BORDER_SIZE, Screen.P
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;
}
当我将窗体拖动到有问题的边框时,按住我的单击按钮,它正在工作,我看到我的高度和宽度发生了变化,但当我释放鼠标时,宽度和高度返回到它们的默认值。
我不明白为什么。
此外,锚不起作用
请问我错过了什么?
提前谢谢
它让我抓狂使用发布的链接解决可能重复的