none
Content in the form are not at the Center . how to do it RRS feed

  • Question


  •     ## Load Language Text from Lang.ini
        Read-LangIni


        $Script:font = New-Object System.Drawing.Font(“Arial",11)
     
        Add-Type -AssemblyName System.Windows.Forms
        $Script:Form = New-Object system.Windows.Forms.Form 
        $Script:Form.Text = "$Script:Title" 
        $Script:Form.TopMost = $Script:true
        $Script:form.StartPosition = $Script:CenterScreen;
        $Script:Form.AutoSize = $Script:true
       
        #$Script:Form.Top= 10
        #$Script:Form.Left =10
        $Script:Form.BackColor = "white"
        $Script:Form.Font = $Script:font
        #$Script:Form.FormBorderStyle = 'Fixed3D'
        $Script:Form.MaximizeBox = $Script:true
        #$Script:Form.MinimizeBox = $Script:true
        $Script:Form.ControlBox = $Script:false
       
        $Script:Form.Add_Shown(
        {
        Write-Host "Form Shown"
            $Script:Form.WindowState = [System.Windows.Forms.FormWindowState]::Maximized
            Write-host "window State = Maximized"
        })

        $Script:GCEBranding = New-Object system.windows.Forms.PictureBox 
        $Script:GCEBranding.Width = 450
        $Script:GCEBranding.Height = 50
        $Script:GCEBranding.ImageLocation = "$Script:scriptDirectory\AppDeployToolkit\AppDeployToolkitBanner.png"
        $Script:GCEBranding.location = new-object system.drawing.point(10,1)
         
        $Script:Form.controls.Add($Script:GCEBranding) 

        $Script:LangSelection = New-Object System.Windows.Forms.ComboBox
        $Script:LangSelection.Location = New-Object System.Drawing.Size(500,30) 
        $Script:LangSelection.AutoSize = $Script:true
        $Script:LangSelection.Height = 80
        $Script:LangSelection.Width = 180
        $Script:LangSelection.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList;
        Get-Content $Script:dirFiles\Languages.txt | ForEach-Object {[void]$Script:LangSelection.Items.Add($_)}
        $Script:LangSelection_SelectedIndexChanged={ChangeLanguage}
        $Script:LangSelection.add_SelectedIndexChanged($Script:LangSelection_SelectedIndexChanged )
        $Script:Form.Controls.Add($Script:LangSelection)
    • Moved by Bill_Stewart Wednesday, May 30, 2018 8:51 PM This is not "teach me programming step-by-step" forum
    Wednesday, April 11, 2018 3:22 PM

Answers

  • do we need use the tablelayoutpanel class .....we tested using startposition ..but its not taking

     $Script:form.StartPosition = $Script:CenterScreen;

     $Script:GCEBranding = New-Object system.windows.Forms.PictureBox 
        $Script:GCEBranding.Width = 450
        $Script:GCEBranding.Height = 50
        $Script:GCEBranding.ImageLocation = "$Script:scriptDirectory\AppDeployToolkit\AppDeployToolkitBanner.png"
        $Script:GCEBranding.location = new-object system.drawing.point(10,1)
         $Script:GCEBranding.StartPosition = $Script:CenterScreen;
        $Script:Form.controls.Add($Script:GCEBranding) 

        $Script:LangSelection = New-Object System.Windows.Forms.ComboBox
        $Script:LangSelection.Location = New-Object System.Drawing.Size(500,30) 
        $Script:LangSelection.AutoSize = $Script:true
        $Script:LangSelection.Height = 80
        $Script:LangSelection.Width = 180
        $Script:LangSelection.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList;
        Get-Content $Script:dirFiles\Languages.txt | ForEach-Object {[void]$Script:LangSelection.Items.Add($_)}
        $Script:LangSelection_SelectedIndexChanged={ChangeLanguage}
        $Script:LangSelection.add_SelectedIndexChanged($Script:LangSelection_SelectedIndexChanged )

    $Script:LangSelection.StartPosition = $Script:CenterScreen;
        $Script:Form.Controls.Add($Script:LangSelection)

    • Marked as answer by KV Anand Thursday, October 25, 2018 2:24 PM
    Thursday, April 12, 2018 9:44 AM

All replies