In my Powershell GUI, I have in the middle, a tablelayout panel. This TableLayoutPanel have three columns. In the last column, I have a FlowLayout Panel.
In this FlowLayout panel I need to add, a random number of labels which depends of what is read in a external xml file. So If my xml have three labels, I need to add three labels.
I'm trying to align theses labels in the middle of the flowlayout panel with a left alignement, like that :
---------------------------- | | | -Label1 | | -Label2 | | -Label3 | | | ----------------------------
But, it's not working, I could have a left alignement, but I don't success in the middle alignement. I have try with "middlecenter", but it's breaking left alignement.
FlowLayout Panel
$HashForAll.PanelLabel=New-Object System.Windows.Forms.FlowLayoutPanel $HashForAll.PanelLabel.FlowDirection = "TopDown" $HashForAll.PanelLabel.WrapContents = $false $HashForAll.PanelLabel.BackColor = [string]$PanelLabelCfg.BackColor $HashForAll.PanelLabel.Name ="PanelLabel" $HashForAll.PanelLabel.BorderStyle =[string]$PanelLabelCfg.BorderStyle $HashForAll.PanelLabel.Dock = "Fill" $HashForAll.MiddleLayout.Controls.Add($HashForAll.PanelLabel,2,0)
And the labels
$sourceXML = [xml](Get-Content $ProductPath\Xml\ConnectionLabels.xml) $etapes = $sourceXML.Dialer.Etapes.Etape $i =1 foreach ($e in $etapes) { $HashForAll.Lbl = New-Object System.Windows.Forms.Label $HashForAll.Lbl.AutoSize =$true $HashForAll.Lbl.Name = "Label"+$i $HashForAll.Lbl.TextAlign = "MiddleLeft" $HashForAll.Lbl.Font = New-Object System.Drawing.Font([string]$lblCfg.Font,[int32]$lblCfg.Size,[System.Drawing.FontStyle]::[string]$lblCfg.Style) $HashForAll.Lbl.ForeColor = [string]$lblCfg.Color $HashForAll.Lbl.Text = $e.Label $HashForAll.PanelLabel.Controls.Add($HashForAll.Lbl) $i++ }