【问题标题】:Windows Forms Application Edits in Designer Modify Form Size and Component Layout在设计器中编辑 Windows 窗体应用程序 修改窗体大小和组件布局
【发布时间】:2018-04-04 22:14:10
【问题描述】:

我有一个奇怪的问题。当我使用 Windows 窗体(使用 Visual Basic)时,有时在设计器中对窗体布局进行编辑会导致窗体大小和组件布局自行更改。我自己没有在这里修改任何东西。以下是我正在谈论的一些图片:

Before Edit

After Edit

我查看了 Designer 文件,这些是关于一个组件的一些示例差异。

编辑前。

    '
    'btnStop
    '
    Me.btnStop.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.btnStop.BackColor = System.Drawing.Color.Red
    Me.btnStop.Enabled = False
    Me.btnStop.Font = New System.Drawing.Font("Microsoft Sans Serif", 60.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnStop.ForeColor = System.Drawing.SystemColors.Control
    Me.btnStop.Location = New System.Drawing.Point(546, 398)
    Me.btnStop.Name = "btnStop"
    Me.btnStop.Size = New System.Drawing.Size(450, 250)
    Me.btnStop.TabIndex = 5
    Me.btnStop.Text = "Stop"
    Me.btnStop.UseVisualStyleBackColor = False

编辑后。

    '
    'btnStop
    '
    Me.btnStop.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.btnStop.BackColor = System.Drawing.Color.Red
    Me.btnStop.Enabled = False
    Me.btnStop.Font = New System.Drawing.Font("Microsoft Sans Serif", 60.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnStop.ForeColor = System.Drawing.SystemColors.Control
    Me.btnStop.Location = New System.Drawing.Point(1092, 765)
    Me.btnStop.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6)
    Me.btnStop.Name = "btnStop"
    Me.btnStop.Size = New System.Drawing.Size(900, 481)
    Me.btnStop.TabIndex = 5
    Me.btnStop.Text = "Stop"
    Me.btnStop.UseVisualStyleBackColor = False

【问题讨论】:

  • 我要检查的第一件事是您的表单的 AutoScaleMode。尝试改变,看看你是否有任何不同。 AutoScaleMode 无 > 字体 > Dpi > 继承

标签: .net vb.net winforms


【解决方案1】:

这通常发生在使用具有不同 DPI 的两台显示器时。因此,例如,如果您使用笔记本电脑和台式显示器来编辑 Windows 窗体屏幕并且显示器具有不同的 DPI,您就会遇到这类问题。

不幸的是,这是一个已知问题,通常最简单的解决方法是确保将显示器缩放设置为 100%。对于其他解决方法,您可以在此处查看:Why does Visual Studio automatically changes the layout of my form?

【讨论】:

  • 那是我的问题。在办公室使用 1080p 显示器,然后在离开时使用我的 Surface Book。我确实发现更改系统的分辨率 / DPI 只有在您更改它然后注销或重新启动时才有效。
猜你喜欢
  • 1970-01-01
  • 2012-05-11
  • 1970-01-01
  • 1970-01-01
  • 2011-09-26
  • 1970-01-01
  • 2011-09-21
  • 1970-01-01
  • 2010-09-05
相关资源
最近更新 更多