I have a simple Windows Form with a TabControl
, but the AutoSize
property doesn't seem to do anything. Here's what it looks like:
Here's my code:
$tabPage = [System.Windows.Forms.TabPage] @{
AutoSize = $true
}
$tabControl = [System.Windows.Forms.TabControl] @{
AutoSize = $true
}
$tabControl.Controls.Add($tabPage)
$form = [System.Windows.Forms.Form] @{
AutoSize = $autoSize
ClientSize = [System.Drawing.Size]::new(300, 300)
}
$form.Controls.Add($tabControl)
I would think the TabControl
should fill the size of the form? I can of course set the Size
or ClientSize
properties, which works fine but I want it to be sized automatically vice setting a static size.
I found this question asking something very similar and the solution provided was to set the Anchor
property, but I tried that and it didn't change anything:
$tabControl.Anchor = @([System.Windows.Forms.AnchorStyles]::Top, [System.Windows.Forms.AnchorStyles]::Left)
So what's the best way to accomplish this without setting a static size?