TableLayoutPanel只显示一行。

huangapple go评论78阅读模式
英文:

TableLayoutPanel only shows one row

问题

我正在使用WinForms构建一个对话框。我有一个面板,我希望在网格中显示4个控件。我正在使用TableLayoutPanel

我希望最终结果看起来像这样:

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)

它看起来像这样:

TableLayoutPanel只显示一行。

如果我将ColumnCount设置为2,它看起来像这样:

TableLayoutPanel只显示一行。

很好,这就是我想要的。但是当我将RowCount设置为2时,它看起来像这样:

TableLayoutPanel只显示一行。

没有任何区别。那么正确的方法是什么呢?

英文:

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:

TableLayoutPanel只显示一行。

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:

TableLayoutPanel只显示一行。

If I set the ColumnCount to 2, it looks like this:

TableLayoutPanel只显示一行。

Great, that's what I want. But then when I set the RowCount to 2, it looks like this:

TableLayoutPanel只显示一行。

No difference. So what's the right way to go about this?

答案1

得分: 0

当我为TableLayoutPanel中的所有控件设置AutoSize = $true时,它按预期工作:

英文:

When I set AutoSize = $true for all the controls within the TableLayoutPanel, it worked as intended:

TableLayoutPanel只显示一行。

huangapple
  • 本文由 发表于 2023年6月1日 07:08:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76377790.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定