首页 > 解决方案 > 移动一个文本框会导致所有文本框和标签移动

问题描述

我正在 Visual Studio 2019 中开发一个 windowsforms vb.net 应用程序,今天我在移动控件时突然开始遇到一个奇怪的问题。

在一个表单上,每当我移动一个文本框时,它都会立即恢复到几乎原来的位置,并且表单上的所有其他文本框和标签都会稍微移动并重新调整大小。在其他表单上,我可以移动控件,但它也会稍微移动其他所有内容。当我查看表单设计器代码时,它来自之前:

  'SpecsButton
        '
        Me.SpecsButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SpecsButton.Location = New System.Drawing.Point(194, 25)
        Me.SpecsButton.Name = "SpecsButton"
        Me.SpecsButton.Size = New System.Drawing.Size(141, 44)
        Me.SpecsButton.TabIndex = 113
        Me.SpecsButton.Text = "Specs"
        Me.SpecsButton.UseVisualStyleBackColor = True
        '
        'CastButton
        '
        Me.CastButton.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.CastButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CastButton.Location = New System.Drawing.Point(28, 25)
        Me.CastButton.Name = "CastButton"
        Me.CastButton.Size = New System.Drawing.Size(147, 44)
        Me.CastButton.TabIndex = 112
        Me.CastButton.Text = "Casts"
        Me.CastButton.UseVisualStyleBackColor = True
        '
        'Button3
        '
        Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button3.Location = New System.Drawing.Point(103, 97)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(154, 42)
        Me.Button3.TabIndex = 111
        Me.Button3.Text = "Exit"
        Me.Button3.UseVisualStyleBackColor = True

并在移动一个按钮后更改为:

SpecsButton
        '
        Me.SpecsButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SpecsButton.Location = New System.Drawing.Point(129, 16)
        Me.SpecsButton.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2)
        Me.SpecsButton.Name = "SpecsButton"
        Me.SpecsButton.Size = New System.Drawing.Size(94, 29)
        Me.SpecsButton.TabIndex = 113
        Me.SpecsButton.Text = "Specs"
        Me.SpecsButton.UseVisualStyleBackColor = True
        '
        'CastButton
        '
        Me.CastButton.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.CastButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CastButton.Location = New System.Drawing.Point(27, 30)
        Me.CastButton.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2)
        Me.CastButton.Name = "CastButton"
        Me.CastButton.Size = New System.Drawing.Size(98, 29)
        Me.CastButton.TabIndex = 112
        Me.CastButton.Text = "Casts"
        Me.CastButton.UseVisualStyleBackColor = True
        '
        'Button3
        '
        Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button3.Location = New System.Drawing.Point(69, 63)
        Me.Button3.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(103, 27)
        Me.Button3.TabIndex = 111
        Me.Button3.Text = "Exit"
        Me.Button3.UseVisualStyleBackColor = True

我对移动一件东西如何改变尺寸、位置以及在某些情况下改变表单上其他所有东西的填充完全感到困惑。

到目前为止我已经尝试过:

更糟糕的是,当我尝试撤消更改时,它并没有把东西放回原来的位置,实际上更多地移动它们!

我截取了一些截图 - 第一个是在尝试移动一个标签之后:

第一的

第二个是单击撤消后,一切都混乱了:

第二

如果有人有任何建议,我将不胜感激,因为现在这使 Visual Studio 无法使用。

标签: vb.netvisual-studiowinformsgithub

解决方案


推荐阅读