英文:
TableLayoutPanel only shows one row
问题
我正在使用WinForms构建一个对话框。我有一个面板,我希望在网格中显示4个控件。我正在使用TableLayoutPanel
。
我希望最终结果看起来像这样:
这是我的代码:
$TableLayoutPanel = [System.Windows.Forms.FlowLayoutPanel] @{
AutoSize = $true
Dock = [System.Windows.Forms.DockStyle]::Fill
}
$TableLayoutPanel.Controls.AddRange(@($name, $email, $phone, $expiration))
$GroupBox = [System.Windows.Forms.GroupBox] @{
Text = "Point of Contact"
}
$GroupBox.Controls.Add($TableLayoutPanel)
它看起来像这样:
如果我将ColumnCount
设置为2,它看起来像这样:
很好,这就是我想要的。但是当我将RowCount
设置为2时,它看起来像这样:
没有任何区别。那么正确的方法是什么呢?
英文:
I'm building a dialog box with WinForms. I have a panel where I want 4 controls to be displayed in a grid. I'm using TableLayoutPanel
.
I want the end result to look like this:
Here's my code:
$TableLayoutPanel = [System.Windows.Forms.FlowLayoutPanel] @{
AutoSize = $true
Dock = [System.Windows.Forms.DockStyle]::Fill
}
$TableLayoutPanel.Controls.AddRange(@($name, $email, $phone, $expiration))
$GroupBox = [System.Windows.Forms.GroupBox] @{
Text = "Point of Contact"
}
$GroupBox.Controls.Add($TableLayoutPanel)
This looks like this:
If I set the ColumnCount
to 2, it looks like this:
Great, that's what I want. But then when I set the RowCount
to 2, it looks like this:
No difference. So what's the right way to go about this?
答案1
得分: 0
当我为TableLayoutPanel
中的所有控件设置AutoSize = $true
时,它按预期工作:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论