none
How to add a group of label from a different runspace in a Powershell GUI? RRS feed

  • Question

  • In my Powershell GUI I have two mode : connection and deconnection. For each there is a list of step. This list is read from a xml and then load into a flowlayout panel, as a label for each step. So If I have 8 steps for connection, I will have 8 labels created in the flowlayout panel.

    I wish to change labels dynamically when my mode change. If I'm in connection mode and switch to the deconnection mode, I need to load the related steps in the flowlayout panel.

    In my script I have three runspace (one for GUI, one for function and one for a timer).

    1-Gui is loaded from GUI runspace without the steps labels

    2-BuiltXML function is executed from Function runspace -> Labels are added in the GUI

    In the Gui runspace, PanelLabelInner (the flowlayoutpanel) is wrapped into a PanelLabelOuter. This is for vertical centering. I need to add the labels into PanelLabelInner.

    I need to finalize BUiltXML function. At first, delete all's the labels when a mode change, and then update the ui to show the new labels : how I can do that ?

    With this code, nothing is added, I suppose I must use something like update, refresh...

    $CommonHashTable.PanelLabelOuter=New-Object System.Windows.Forms.Panel
    $CommonHashTable.PanelLabelOuter.BackColor = [string]$PanelLabelOuterCfg.BackColor
    $CommonHashTable.PanelLabelOuter.Name ="PanelLabelOuter"
    $CommonHashTable.PanelLabelOuter.BorderStyle =[string]$PanelLabelOuterCfg.BorderStyle
    $CommonHashTable.PanelLabelOuter.Dock = "Fill"
    $CommonHashTable.PanelLabelOuter.AutoSize = $false
    $CommonHashTable.MiddleLayout.Controls.Add($CommonHashTable.PanelLabelOuter,2,0)
    
    $CommonHashTable.PanelLabelInner=New-Object System.Windows.Forms.FlowLayoutPanel
    $CommonHashTable.PanelLabelInner.AutoSize = $false
    $CommonHashTable.PanelLabelInner.Height = $CommonHashTable.c*20
    $CommonHashTable.PanelLabelInner.Left = [Int32]$PanelLabelInnerCfg.Left
    $CommonHashTable.PanelLabelInner.Width= $CommonHashTable.PanelLabelOuter.Width
    $top=[int32](($CommonHashTable.PanelLabelOuter.Size.Height -  $CommonHashTable.PanelLabelInner.Size.Height) / 2)
    $CommonHashTable.PanelLabelInner.Top=$top
    $CommonHashTable.PanelLabelInner.Padding= 0
    $CommonHashTable.PanelLabelInner.Anchor = 'None'
    $CommonHashTable.PanelLabelInner.FlowDirection = "TopDown"
    $CommonHashTable.PanelLabelInner.WrapContents = $false
    $CommonHashTable.PanelLabelInner.BackColor = [string]$PanelLabelInnerCfg.BackColor
    $CommonHashTable.PanelLabelInner.Name ="PanelLabelInner"
    $CommonHashTable.PanelLabelOuter.Controls.Add($CommonHashTable.PanelLabelInner)

    And the BuiltXML function in the function runspace

    function BuiltXML{
            Switch ($CommonHashTable.Phase) {
                        {$CommonHashTable.Phase -eq "Connect"}
                            {
                                    $ConnectLabelText = "Connection"
                                    $CommonHashTable.sourceXML = [xml](Get-Content $ProductPath\Xml\ConnectionLabels.xml)
    
                            }
    
                        {$CommonHashTable.Phase -eq "Disconnect"}
                            {
                                    $ConnectLabelText = "Logout"
                                    $CommonHashTable.sourceXML = [xml](Get-Content $ProductPath\Xml\DeconnectionLabels.xml)
                            }
            }
            $CommonHashTable.steps= $CommonHashTable.sourceXML.Dialer.Steps.Stp
            $CommonHashTable.c = $CommonHashTable.steps.count
            $CommonHashTable.PanelLabelInner.Invoke([Action[string]] {
                $i =1
                    #$CommonHashTable.PanelLabelInner.Controls.Remove($CommonHashTable.Lbl)
                    $CommonHashTable.Lbl.Controls.Clear()
                    foreach ($e in $CommonHashTable.steps) 
                    {
                        $CommonHashTable.Lbl = New-Object System.Windows.Forms.Label
                        $CommonHashTable.Lbl.Size=New-Object System.Drawing.Size($CommonHashTable.PanelLabelInner.Size.Width,20) 
                        $CommonHashTable.Lbl.AutoSize = $false
                        $CommonHashTable.Lbl.Name = "Label"+$i
                        $CommonHashTable.Lbl.TextAlign = "MiddleLeft"
                        $CommonHashTable.Lbl.Text = $e.Label
                        $CommonHashTable.PanelLabelInner.Controls.Add($CommonHashTable.Lbl)
                        $i++
                    }
                },
            'normal')
    }

    Thursday, July 21, 2016 12:40 PM

Answers

  • Updating a single label is much different from what you are doing.  You have everything in the hash.  All code that updates a form needs to be in the runspace.

    The better design is to run a form that manages action runspaces.   The form would then poll the runspaces and report status.  That is the usual design pattern.  You are approaching it backwards and this is making you whole problem much bigger and more difficult.

    Aside from that you have not really asked a clear question.

    WPF is a very technical complex framework.  It is designed to work with "code behind" in a compiled environment.  Yes we can use it in PowerShell but that means accepting many limitations of the "late bound" environment.

    Unless you have very good programming skills you will find using XAML for more than a simple form will be a challenge. 

    We can answer specific questions but not vague allusions to a form that is not visible and with a discussion that has too little context.  In other words we cannot know what is in your head.

    Start by posting a simple form that works and a simple example of what you are trying to do with a simple explanation of what is not happening or the errors you are getting.


    \_(ツ)_/

    • Marked as answer by MrFlamby Friday, July 22, 2016 9:52 AM
    Thursday, July 21, 2016 2:02 PM

All replies

  • Why would you do this in a runspace?  Why would you want all controls to be accessed through a synchash.  This is not qa good way to build forms and will be very hard to manage.

    Start by building a classic form and adding all functionality into the form.  When that I working then you can wrap it in a runspace if that adds functionality.


    \_(ツ)_/

    Thursday, July 21, 2016 1:19 PM
  • If you want a form to update itself then send the form a message saying to update.  This will be easier to code and is a more normal design approach.

    \_(ツ)_/

    Thursday, July 21, 2016 1:20 PM
  • When a step is completed in the function runspace, we need to update the text label to show that this step is completed (like font-weight normal => bold). That's why we need to have an access to the controls from another runspace. I have also a Webbrowser in the GUI. For every step, I use this access to navigate to a html information page related to the step.

    For example, If I want to update, I have to do something like that ?

     $CommonHashTable.PanelLabelInner.Update()

    Thursday, July 21, 2016 1:44 PM
  • Updating a single label is much different from what you are doing.  You have everything in the hash.  All code that updates a form needs to be in the runspace.

    The better design is to run a form that manages action runspaces.   The form would then poll the runspaces and report status.  That is the usual design pattern.  You are approaching it backwards and this is making you whole problem much bigger and more difficult.

    Aside from that you have not really asked a clear question.

    WPF is a very technical complex framework.  It is designed to work with "code behind" in a compiled environment.  Yes we can use it in PowerShell but that means accepting many limitations of the "late bound" environment.

    Unless you have very good programming skills you will find using XAML for more than a simple form will be a challenge. 

    We can answer specific questions but not vague allusions to a form that is not visible and with a discussion that has too little context.  In other words we cannot know what is in your head.

    Start by posting a simple form that works and a simple example of what you are trying to do with a simple explanation of what is not happening or the errors you are getting.


    \_(ツ)_/

    • Marked as answer by MrFlamby Friday, July 22, 2016 9:52 AM
    Thursday, July 21, 2016 2:02 PM
  • Thanks you very much for your advice. My post wasn't enough complete... I will be more clear next times.

    I've found a solution for my problem. For that, I have started to built a independant form :

    [string]$ProductName='Test'
    [string]$ProductPath='c:\Temp'
    
    [int32]$Width=600
    [int32]$Height=760
    
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing
    
    $MainForm=New-Object System.Windows.Forms.Form
    $MainForm.Size=New-Object System.Drawing.Size($Width,$Height)
    $MainForm.StartPosition="CenterScreen"
    $MainForm.FormBorderStyle=[System.Windows.Forms.FormBorderStyle]::FixedDialog
    $MainForm.MaximizeBox=$False
    $MainForm.MinimizeBox=$False
    $MainForm.ShowInTaskbar=$True
    $MainForm.WindowState="Normal"
    $MainForm.Name="MainForm"
    $MainForm.DataBindings.DefaultDataSourceUpdateMode = 0
    
        $GeneralLayout = New-Object System.Windows.Forms.TableLayoutPanel
        $GeneralLayout.RowCount = 3
        $GeneralLayout.ColumnCount = 1 
        $GeneralLayout.TabIndex = 1
        $GeneralLayout.Padding = 5
        $GeneralLayout.Name="GeneralLayout"
        $GeneralLayout.Dock ="fill"
        $GeneralLayout.Height = $Height
        $GeneralLayout.RowStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 12)))
        $GeneralLayout.RowStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 27)))
        $GeneralLayout.RowStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 63)))
        $MainForm.Controls.Add($GeneralLayout)
    
            $TopLayout = New-Object System.Windows.Forms.Panel
            $TopLayout.Dock ="top"
            $TopLayout.Name ="PanelLogo"
            $TopLayout.AutoSize =$false
            $TopLayout.add_paint({$brush = new-object System.Drawing.Drawing2D.LinearGradientBrush((new-object system.drawing.point 0,0),(new-object system.drawing.point($this.clientrectangle.width,$this.clientrectangle.height)),[System.Drawing.ColorTranslator]::FromHtml('#00205b'),[System.Drawing.ColorTranslator]::FromHtml('#ffffff'))
                $_.graphics.fillrectangle($brush,$this.clientrectangle)
            })
            $TopLayout.BorderStyle ="FixedSingle"        
            $GeneralLayout.Controls.Add($TopLayout,0,0)
    
        $MiddleLayout = New-Object System.Windows.Forms.TableLayoutPanel
        $MiddleLayout.RowCount = 1
        $MiddleLayout.ColumnCount = 3 
        $MiddleLayout.TabIndex = 1
        $MiddleLayout.Margin=0
        $MiddleLayout.Padding=0
        $MiddleLayout.Name="MiddleLayout"
        $MiddleLayout.Dock ="fill"
        $MiddleLayout.CellBorderStyle = "None"
        $MiddleLayout.RowStyles.Add((new-object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 100)))
        $MiddleLayout.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 30)))
        $MiddleLayout.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 1)))
        $MiddleLayout.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 69)))
        $GeneralLayout.Controls.Add($MiddleLayout,0,1)
    
        $PanelConnect = New-Object System.Windows.Forms.Panel
        $PanelConnect.BackColor = [System.Drawing.ColorTranslator]::FromHtml('#00205b')
        $PanelConnect.BorderStyle ="FixedSingle"
        $PanelConnect.Dock = "fill"
        $MiddleLayout.Controls.Add($PanelConnect,0,0)
       
                $ConnectLabel = New-Object System.Windows.Forms.Label
                $ConnectLabel.AutoSize = $false
                $ConnectLabel.Dock = "Fill"
                $ConnectLabel.Name = "labellogo"
                $ConnectLabel.Font = New-Object System.Drawing.Font("HelveticaNeueLT Com 55 Roman",14,[System.Drawing.FontStyle]::Bold)
                $ConnectLabel.ForeColor = [System.Drawing.ColorTranslator]::FromHtml('#e0e0df')   
                $ConnectLabel.TextAlign="MiddleCenter"
                $ConnectLabel.Text=$ConnectLabelText
                $PanelConnect.Controls.Add($ConnectLabel)
    
        $PanelLabelOuter=New-Object System.Windows.Forms.Panel
        $PanelLabelOuter.BackColor = "white"
        $PanelLabelOuter.Name ="PanelLabelOuter"
        $PanelLabelOuter.BorderStyle ="FixedSingle"
        $PanelLabelOuter.Dock = "Fill"
        $PanelLabelOuter.AutoSize = $false
        $MiddleLayout.Controls.Add($PanelLabelOuter,2,0)
    
        $PanelLabelInner=New-Object System.Windows.Forms.FlowLayoutPanel
        $PanelLabelInner.AutoSize = $false
        $PanelLabelInner.Height = $c*20
        $PanelLabelInner.Left = 20
        $PanelLabelInner.Width= $PanelLabelOuter.Width
        $top=[int32](($PanelLabelOuter.Size.Height -  $PanelLabelInner.Size.Height) / 2)
        $PanelLabelInner.Top=$top
        $PanelLabelInner.Padding= 0
        $PanelLabelInner.Anchor = 'None'
        $PanelLabelInner.FlowDirection = "TopDown"
        $PanelLabelInner.WrapContents = $false
        $PanelLabelInner.BackColor = "white"
        $PanelLabelInner.Name ="PanelLabelInner"
        $PanelLabelOuter.Controls.Add($PanelLabelInner)
            <#
            $i =1
            foreach ($e in $steps) 
            {
                $CommonHashTable.Lbl = New-Object System.Windows.Forms.Label
                $CommonHashTable.Lbl.Size=New-Object System.Drawing.Size($CommonHashTable.PanelLabelInner.Size.Width,20) 
                $CommonHashTable.Lbl.AutoSize = $false
                $CommonHashTable.Lbl.Name = "Label"+$i
                $CommonHashTable.Lbl.TextAlign = "MiddleLeft"
                $CommonHashTable.Lbl.Font = New-Object System.Drawing.Font("HelveticaNeueLT Com 55 Roman",10,[System.Drawing.FontStyle]::Regular)
                $CommonHashTable.Lbl.ForeColor = "Silver"
                $CommonHashTable.Lbl.Text = $e.Label #On s'appuie sur le XML pour le contenu des labels
                $CommonHashTable.PanelLabelInner.Controls.Add($CommonHashTable.Lbl)
                $i++
            }       
            #>
        $PanelWeb = New-Object System.Windows.Forms.Panel
        $PanelWeb.AutoSize = $false
        $PanelWeb.BorderStyle ="FixedSingle"
        $PanelWeb.Dock ="fill"
        $GeneralLayout.Controls.Add($PanelWeb,0,2)
    
            $InfoBrowser = new-object System.Windows.Forms.WebBrowser
            $InfoBrowser.Dock ="fill"
            $InfoBrowser.ScrollBarsEnabled = $true
            $InfoBrowser.IsWebBrowserContextMenuEnabled = $false
            $InfoBrowser.AllowWebBrowserDrop = $false
            $PanelWeb.Controls.Add($InfoBrowser)  
    
    
    $InitialFormWindowState = $MainForm.WindowState
    
    $MainForm.add_Load({
        $MainForm.WindowState = $InitialFormWindowState
    })
    
    $Runspace = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($Host)
    $Runspace.ApartmentState = 'STA'
    $Runspace.ThreadOptions = 'ReuseThread'
    $Runspace.Open()
    $Runspace.SessionStateProxy.SetVariable('MainForm', $MainForm)
    
    
    $PowerShellRunspace = [System.Management.Automation.PowerShell]::Create()
    $PowerShellRunspace.Runspace = $Runspace
    $PowerShellRunspace.AddScript(
    {
    [System.Windows.Forms.Application]::EnableVisualStyles()
    [System.Windows.Forms.Application]::Run($MainForm)
    
    })
    
    $AsyncResult = $PowerShellRunspace.BeginInvoke()
    
    $Phase = "Disconnect"
     Switch ($Phase) {
    		{$Phase -eq "Connect"}
                {
                    
                        $ConnectLabel.Text = "Connection"
                        $sourceXML = [xml](Get-Content $ProductPath\Connection.xml)
                }
    	
    		{$Phase -eq "Disconnect"}
                {
                        $ConnectLabel.Text = "Deconnection"
                        $sourceXML = [xml](Get-Content $ProductPath\Deconnection.xml)
                }
    	}
    
            $steps = $sourceXML.Dialer.Steps.Stp 
            $c = $steps.count
    
     $PanelLabelInner.Invoke(
     [Action] {
                  $PanelLabelInner.Controls.Clear()
                   $i =1
                    foreach ($e in $steps) 
                    {
                         
                        $Lbl = New-Object System.Windows.Forms.Label
                        $Lbl.Size=New-Object System.Drawing.Size($PanelLabelInner.Size.Width,20) 
                        $Lbl.AutoSize = $false
                        $Lbl.Name = "Label"+$i
                        $Lbl.TextAlign = "MiddleLeft"
                        #$CommonHashTable.Lbl.Font = New-Object System.Drawing.Font([string]$lblCfg.Font,[int32]$lblCfg.Size,[System.Drawing.FontStyle]::[string]$lblCfg.Style)
                        #$CommonHashTable.Lbl.ForeColor = [string]$lblCfg.Color
                        $Lbl.Text = $e.Label #On s'appuie sur le XML pour le contenu des labels
                        $PanelLabelInner.Controls.Add($Lbl)
     
                        $i++
                    }
               }
        )
        
     start-sleep -s 1
    
     
    $Phase = "Connect"
     Switch ($Phase) {
    		{$Phase -eq "Connect"}
                {
                    
                        $ConnectLabel.Text = "Connection"
                        $sourceXML = [xml](Get-Content $ProductPath\Connection.xml)
                }
    	
    		{$Phase -eq "Disconnect"}
                {
                        $ConnectLabel.Text = "Deconnection"
                        $sourceXML = [xml](Get-Content $ProductPath\Deconnection.xml)
                }
    	}
    
            $steps = $sourceXML.Dialer.Steps.Stp 
            $c = $steps.count
    
     $PanelLabelInner.Invoke(
     [Action] {
                  $PanelLabelInner.Controls.Clear()
                   $i =1
                    foreach ($e in $steps) 
                    {
                         
                        $Lbl = New-Object System.Windows.Forms.Label
                        $Lbl.Size=New-Object System.Drawing.Size($PanelLabelInner.Size.Width,20) 
                        $Lbl.AutoSize = $false
                        $Lbl.Name = "Label"+$i
                        $Lbl.TextAlign = "MiddleLeft"
                        #$CommonHashTable.Lbl.Font = New-Object System.Drawing.Font([string]$lblCfg.Font,[int32]$lblCfg.Size,[System.Drawing.FontStyle]::[string]$lblCfg.Style)
                        #$CommonHashTable.Lbl.ForeColor = [string]$lblCfg.Color
                        $Lbl.Text = $e.Label #On s'appuie sur le XML pour le contenu des labels
                        $PanelLabelInner.Controls.Add($Lbl)
     
                        $i++
                    }
                     $PanelLabelInner.update()
               }
        )
     start-sleep -s 1
    
    $Phase = "Disconnect"
     Switch ($Phase) {
    		{$Phase -eq "Connect"}
                {
                    
                        $ConnectLabel.Text = "Connection"
                        $sourceXML = [xml](Get-Content $ProductPath\Connection.xml)
                }
    	
    		{$Phase -eq "Disconnect"}
                {
                        $ConnectLabel.Text = "Deconnection"
                        $sourceXML = [xml](Get-Content $ProductPath\Deconnection.xml)
                }
    	}
    
            $steps = $sourceXML.Dialer.Steps.Stp 
            $c = $steps.count
    
     $PanelLabelInner.Invoke(
     [Action] {
                  $PanelLabelInner.Controls.Clear()
                   $i =1
                    foreach ($e in $steps) 
                    {
                         
                        $Lbl = New-Object System.Windows.Forms.Label
                        $Lbl.Size=New-Object System.Drawing.Size($PanelLabelInner.Size.Width,20) 
                        $Lbl.AutoSize = $false
                        $Lbl.Name = "Label"+$i
                        $Lbl.TextAlign = "MiddleLeft"
                        #$CommonHashTable.Lbl.Font = New-Object System.Drawing.Font([string]$lblCfg.Font,[int32]$lblCfg.Size,[System.Drawing.FontStyle]::[string]$lblCfg.Style)
                        #$CommonHashTable.Lbl.ForeColor = [string]$lblCfg.Color
                        $Lbl.Text = $e.Label #On s'appuie sur le XML pour le contenu des labels
                        $PanelLabelInner.Controls.Add($Lbl)
     
                        $i++
                    }
                     $PanelLabelInner.update()
               }
        )

    With this XML sample for connection

    <?xml version="1.0" encoding="utf-8"?>
    <Dialer>
      <Steps>
        <Stp num="Step 1">
          <Label>Step 1 for connection</Label>
        </Stp>
        <Stp num="Step 2">
          <Label>Step 2 for connection</Label>
        </Stp>
        <Stp num="Step 3">
          <Label>Step 3 for connection</Label>
        </Stp>
        <Stp num="Step 4">
          <Label>Step 4 for connection</Label>
        </Stp>
      </Steps>
    </Dialer>

    and for deconnection :

    <?xml version="1.0" encoding="utf-8"?>
    <Dialer>
      <Steps>
        <Stp num="Step 1">
          <Label>Step 1 for deconnection</Label>
        </Stp>
        <Stp num="Step 2">
          <Label>Step 2 for deconnection</Label>
        </Stp>
        <Stp num="Step 3">
          <Label>Step 3 for deconnection</Label>
        </Stp>
        <Stp num="Step 4">
          <Label>Step 4 for deconnection</Label>
        </Stp>
      </Steps>
    </Dialer>

    The main idea was to built the form in connection mode and then switch to deconnection and re-switch to connection.  And it's worked ! Then I have try to apply that in my true script... after few hours of testing, I've found a solution. It's not the best.. but for the moment, it's ok.

    So now, when I need to add my labels :

    • 1-I Clear the outer wrap panel 
    • 2-I add the inner flowlayout panel which height is related to number of labels
    • 3-I add the labels in the inner flowlayout panel
    • 4-Update of outer wrap panel
    function BuiltXML{
            Switch ($CommonHashTable.Phase) {
    		            {$CommonHashTable.Phase -eq "Connect"}
                            {
                                    $CommonHashTable.ConnectLabel.Text = "Connection"
                                    $sourceXML = [xml](Get-Content $ProductPath\Xml\ConnectionLabels.xml)
         
                            }
    	
    		            {$CommonHashTable.Phase -eq "Disconnect"}
                            {
                                    $CommonHashTable.ConnectLabel.Text = "Logout"
                                    $sourceXML = [xml](Get-Content $ProductPath\Xml\DeconnectionLabels.xml)
                            }
            }
    
             $etapes = $sourceXML.Dialer.Etapes.Etape 
             $c = $etapes.count
             $CommonHashTable.PanelLabelOuter.Invoke(
             [Action] {
    
                $CommonHashTable.PanelLabelOuter.Controls.Clear()
                    $CommonHashTable.PanelLabelInner=New-Object System.Windows.Forms.FlowLayoutPanel
                    $CommonHashTable.PanelLabelInner.AutoSize = $false
                    $CommonHashTable.PanelLabelInner.Height = $c*20
                    $CommonHashTable.PanelLabelInner.Left = [Int32]$PanelLabelInnerCfg.Left
                    $CommonHashTable.PanelLabelInner.Width= $CommonHashTable.PanelLabelOuter.Width
                    $top=[int32](($CommonHashTable.PanelLabelOuter.Size.Height -  $CommonHashTable.PanelLabelInner.Size.Height) / 2)
                    $CommonHashTable.PanelLabelInner.Top=$top
                    $CommonHashTable.PanelLabelInner.Padding= 0
                    $CommonHashTable.PanelLabelInner.Anchor = 'None'
                    $CommonHashTable.PanelLabelInner.FlowDirection = "TopDown"
                    $CommonHashTable.PanelLabelInner.WrapContents = $false
                    $CommonHashTable.PanelLabelInner.BackColor = [string]$PanelLabelInnerCfg.BackColor
                    $CommonHashTable.PanelLabelInner.Name ="PanelLabelInner"
                    $CommonHashTable.PanelLabelOuter.Controls.Add($CommonHashTable.PanelLabelInner)
                    
                    $i =1
    
                    foreach ($e in $etapes) 
                    {
                        $CommonHashTable.Lbl = New-Object System.Windows.Forms.Label
                        $CommonHashTable.Lbl.Size=New-Object System.Drawing.Size($CommonHashTable.PanelLabelInner.Size.Width,20) 
                        $CommonHashTable.Lbl.AutoSize = $false
                        $CommonHashTable.Lbl.Name = "Label"+$i
                        $CommonHashTable.Lbl.TextAlign = "MiddleLeft"
                        #$CommonHashTable.Lbl.Font = New-Object System.Drawing.Font([string]$lblCfg.Font,[int32]$lblCfg.Size,[System.Drawing.FontStyle]::[string]$lblCfg.Style)
                        #$CommonHashTable.Lbl.ForeColor = [string]$lblCfg.Color
                        $CommonHashTable.Lbl.Text = $e.Label
                        $CommonHashTable.PanelLabelInner.Controls.Add($CommonHashTable.Lbl)
                        $i++
                    }
                        $CommonHashTable.PanelLabelInner.update()
                } 
            )
    }


    • Edited by MrFlamby Friday, July 22, 2016 9:52 AM
    • Proposed as answer by jrv Friday, July 22, 2016 11:24 AM
    Friday, July 22, 2016 9:49 AM
  • McFlamy - looks like good work.  It would be better and more persistent if you were to do a blog post with a more complete explanation of the problem and how you solved it.  Others may find it useful and may not wish to read a whole forum thread and try to decode the result.

    Glad you have a solution.


    \_(ツ)_/

    Friday, July 22, 2016 11:24 AM