Vb.net 不同计算机上控件的位置

Vb.net 不同计算机上控件的位置,vb.net,Vb.net,我有一个带有选项卡控件的表单。上面有标签、组合框和文本框。 在开发机器上,它可以正常工作,但在分辨率不同的其他机器上,控件的位置会改变。组合框与选项卡控件重叠,文本框和标签不对齐 如何设置它,使我的应用程序无论分辨率如何都能保持形状 我尝试自动缩放模式到dpi、继承等,但没有任何效果 谢谢我总是使用布局面板,尤其是TableLayoutPanel。对于包含组合框或文本框的任何行,我将行的高度设置为自动调整大小。类似地,标签将显示在“自动调整大小”列中。选项卡面板可以跨越多个列。在设置了“绝对大小

我有一个带有选项卡控件的表单。上面有标签、组合框和文本框。 在开发机器上,它可以正常工作,但在分辨率不同的其他机器上,控件的位置会改变。组合框与选项卡控件重叠,文本框和标签不对齐

如何设置它,使我的应用程序无论分辨率如何都能保持形状

我尝试自动缩放模式到dpi、继承等,但没有任何效果


谢谢

我总是使用布局面板,尤其是TableLayoutPanel。对于包含组合框或文本框的任何行,我将行的高度设置为自动调整大小。类似地,标签将显示在“自动调整大小”列中。选项卡面板可以跨越多个列。在设置了“绝对大小”或“百分比”的列中,将子控件的定位设置为“左”和“右”,以填充整个列

不仅屏幕分辨率会改变事情,DPI也会改变。DPI是一种Windows设置,可放大所有控件,适用于具有精细像素而非块状像素的显示器。使用AutoSize,控件可以自动放大,然后

例如,将此代码复制并粘贴到Form1.Designer.vb中。注意每个控件的锚属性,以及每行和每列的大小设置

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    Try
        If disposing AndAlso components IsNot Nothing Then
        components.Dispose()
        End If
    Finally
        MyBase.Dispose(disposing)
    End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
    Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.ComboBox1 = New System.Windows.Forms.ComboBox()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.TextBox1 = New System.Windows.Forms.TextBox()
    Me.TabControl1 = New System.Windows.Forms.TabControl()
    Me.TabPage1 = New System.Windows.Forms.TabPage()
    Me.TabPage2 = New System.Windows.Forms.TabPage()
    Me.TableLayoutPanel1.SuspendLayout()
    Me.TabControl1.SuspendLayout()
    Me.SuspendLayout()
    '
    'TableLayoutPanel1
    '
    Me.TableLayoutPanel1.ColumnCount = 4
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle())
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle())
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.ComboBox1, 1, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.Label2, 2, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.TextBox1, 3, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.TabControl1, 0, 1)
    Me.TableLayoutPanel1.Location = New System.Drawing.Point(12, 12)
    Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
    Me.TableLayoutPanel1.RowCount = 2
    Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
    Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
    Me.TableLayoutPanel1.Size = New System.Drawing.Size(260, 238)
    Me.TableLayoutPanel1.TabIndex = 0
    '
    'Label1
    '
    Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.Right
    Me.Label1.AutoSize = True
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Label1"
    '
    'ComboBox1
    '
    Me.ComboBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.ComboBox1.FormattingEnabled = True
    Me.ComboBox1.Name = "ComboBox1"
    Me.ComboBox1.TabIndex = 1
    '
    'Label2
    '
    Me.Label2.Anchor = System.Windows.Forms.AnchorStyles.Right
    Me.Label2.AutoSize = True
    Me.Label2.Name = "Label2"
    Me.Label2.TabIndex = 2
    Me.Label2.Text = "Label2"
    '
    'TextBox1
    '
    Me.TextBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.TextBox1.Name = "TextBox1"
    Me.TextBox1.TabIndex = 3
    '
    'TabControl1
    '
    Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
        Or System.Windows.Forms.AnchorStyles.Left) _
        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.TableLayoutPanel1.SetColumnSpan(Me.TabControl1, 4)
    Me.TabControl1.Controls.Add(Me.TabPage1)
    Me.TabControl1.Controls.Add(Me.TabPage2)
    Me.TabControl1.Name = "TabControl1"
    Me.TabControl1.TabIndex = 4
    '
    'TabPage1
    '
    Me.TabPage1.Name = "TabPage1"
    Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
    Me.TabPage1.TabIndex = 0
    Me.TabPage1.Text = "TabPage1"
    Me.TabPage1.UseVisualStyleBackColor = True
    '
    'TabPage2
    '
    Me.TabPage2.Name = "TabPage2"
    Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
    Me.TabPage2.TabIndex = 1
    Me.TabPage2.Text = "TabPage2"
    Me.TabPage2.UseVisualStyleBackColor = True
    '
    'Form1
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(284, 262)
    Me.Controls.Add(Me.TableLayoutPanel1)
    Me.Name = "Form1"
    Me.Text = "Form1"
    Me.TableLayoutPanel1.ResumeLayout(False)
    Me.TableLayoutPanel1.PerformLayout()
    Me.TabControl1.ResumeLayout(False)
    Me.ResumeLayout(False)

    End Sub
    Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage

End Class