【问题标题】:Drag a form to the screen borders to change its height/width将表单拖动到屏幕边框以更改其高度/宽度
【发布时间】:2012-02-16 15:33:53
【问题描述】:

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

    }

当我将表单拖到有问题的边框时(按住我的点击)它正在工作,我看到我的高度和宽度发生了变化,但是当我释放鼠标时,宽度和高度又回到了它们的默认值。 我不明白为什么。 而且,锚点不起作用。

请问我错过了什么? 提前致谢 这让我发疯了

【问题讨论】:

标签: c# .net anchor dock


【解决方案1】:

使用发布的链接解决

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 2012-11-01
    • 2011-09-09
    • 2012-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多