Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将窗体拖动到屏幕边框以更改其高度/宽度_C#_.net_Anchor_Dock - Fatal编程技术网

C# 将窗体拖动到屏幕边框以更改其高度/宽度

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

在我的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;

    }
当我将窗体拖动到有问题的边框时,按住我的单击按钮,它正在工作,我看到我的高度和宽度发生了变化,但当我释放鼠标时,宽度和高度返回到它们的默认值。 我不明白为什么。 此外,锚不起作用

请问我错过了什么? 提前谢谢
它让我抓狂

使用发布的链接解决

可能重复的