Advertisement
Guest User

Powershell forms resizing

a guest
May 20th, 2019
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. Add-Type -AssemblyName System.Windows.Forms
  2. Add-Type -AssemblyName System.Drawing
  3. [System.Windows.Forms.Application]::EnableVisualStyles()
  4.  
  5. $Form = New-Object system.Windows.Forms.Form
  6. $Form.ClientSize = '500,230'
  7. $Form.text = "Some title"
  8. $Form.StartPosition = 'CenterScreen'
  9.  
  10. $Button1 = New-Object System.Windows.Forms.Button
  11. # $Button1.Location = New-Object System.Drawing.Point(200,150)
  12. # $Button1.Size = New-Object System.Drawing.Size(100,50)
  13. $Button1.Text = "START"
  14. $Button1.Anchor = [System.Windows.Forms.AnchorStyles]::Top `
  15. -bor [System.Windows.Forms.AnchorStyles]::Bottom `
  16. -bor [System.Windows.Forms.AnchorStyles]::Left `
  17. -bor [System.Windows.Forms.AnchorStyles]::Right
  18.  
  19.  
  20. $ListBox1 = New-Object system.Windows.Forms.ListBox
  21. $ListBox1.text = "listBox"
  22. # $ListBox1.location = New-Object System.Drawing.Point(50,50)
  23. # $ListBox1.size = New-Object System.Drawing.Size(50,50)
  24. $ListBox1.Anchor = [System.Windows.Forms.AnchorStyles]::Top `
  25. -bor [System.Windows.Forms.AnchorStyles]::Bottom `
  26. -bor [System.Windows.Forms.AnchorStyles]::Left `
  27. -bor [System.Windows.Forms.AnchorStyles]::Right
  28.  
  29. $tableLayoutPanel1 = New-Object System.Windows.Forms.TableLayoutPanel
  30. $tableLayoutPanel1.RowCount = 2
  31. $tableLayoutPanel1.ColumnCount = 2
  32. # $tableLayoutPanel1.SetColumnSpan($Button1,2)
  33. #$tableLayoutPanel1.SetRowSpan($Button1,2)
  34. $tableLayoutPanel1.Controls.Add($Button1, 0, 0)
  35. $tableLayoutPanel1.Controls.Add($ListBox1, 1, 1)
  36. $tableLayoutPanel1.Dock = [System.Windows.Forms.DockStyle]::Fill
  37. $tableLayoutPanel1.RowStyles.Add((new-object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 50)))
  38. $tableLayoutPanel1.RowStyles.Add((new-object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 50)))
  39. $tableLayoutPanel1.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent,50)))
  40. $tableLayoutPanel1.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent,50)))
  41.  
  42. $Form.controls.AddRange(@($tableLayoutPanel1))
  43. $Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement