PowerShell GUI TabControl

Good afternoon All,
First off hello from me (Chris).
I have just started using Powershell (Yesterday) and I am struggling to do what I need.
I am trying to create a TabControl with 11-12 Tabs down the left handside.

I have very limited knowledge and most of my coding is what I have learned searching online.

Can anyone help please.

Thanks all.

Chris

I’m not a sapien salesman but I definitely recommend it for the heavy lifting. I created this under a minute.

#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 3cb5e444-0af7-47a6-b58a-a544bff30aac
# Source File: \tabcontrol.psf
#------------------------------------------------------------------------


#----------------------------------------------
#region Application Functions
#----------------------------------------------

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Show-tabcontrol_psf {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
	[void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
	[void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$form1 = New-Object 'System.Windows.Forms.Form'
	$tabcontrol1 = New-Object 'System.Windows.Forms.TabControl'
	$tabpage1 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage2 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage3 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage4 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage5 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage6 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage7 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage8 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage9 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage10 = New-Object 'System.Windows.Forms.TabPage'
	$tabpage11 = New-Object 'System.Windows.Forms.TabPage'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	$form1_Load={
		
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$form1.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$form1.remove_Load($form1_Load)
			$form1.remove_Load($Form_StateCorrection_Load)
			$form1.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch { Out-Null  }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	$form1.SuspendLayout()
	$tabcontrol1.SuspendLayout()
	#
	# form1
	#
	$form1.Controls.Add($tabcontrol1)
	$form1.AutoScaleDimensions = '6, 13'
	$form1.AutoScaleMode = 'Font'
	$form1.ClientSize = '653, 717'
	$form1.Name = 'form1'
	$form1.Text = 'Form'
	$form1.add_Load($form1_Load)
	#
	# tabcontrol1
	#
	$tabcontrol1.Controls.Add($tabpage1)
	$tabcontrol1.Controls.Add($tabpage2)
	$tabcontrol1.Controls.Add($tabpage3)
	$tabcontrol1.Controls.Add($tabpage4)
	$tabcontrol1.Controls.Add($tabpage5)
	$tabcontrol1.Controls.Add($tabpage6)
	$tabcontrol1.Controls.Add($tabpage7)
	$tabcontrol1.Controls.Add($tabpage8)
	$tabcontrol1.Controls.Add($tabpage9)
	$tabcontrol1.Controls.Add($tabpage10)
	$tabcontrol1.Controls.Add($tabpage11)
	$tabcontrol1.Alignment = 'Left'
	$tabcontrol1.Location = '12, 12'
	$tabcontrol1.Multiline = $True
	$tabcontrol1.Name = 'tabcontrol1'
	$tabcontrol1.SelectedIndex = 0
	$tabcontrol1.Size = '629, 678'
	$tabcontrol1.TabIndex = 0
	#
	# tabpage1
	#
	$tabpage1.Location = '42, 4'
	$tabpage1.Name = 'tabpage1'
	$tabpage1.Padding = '3, 3, 3, 3'
	$tabpage1.Size = '583, 442'
	$tabpage1.TabIndex = 0
	$tabpage1.Text = 'tabpage1'
	$tabpage1.UseVisualStyleBackColor = $True
	#
	# tabpage2
	#
	$tabpage2.Location = '23, 4'
	$tabpage2.Name = 'tabpage2'
	$tabpage2.Padding = '3, 3, 3, 3'
	$tabpage2.Size = '602, 442'
	$tabpage2.TabIndex = 1
	$tabpage2.Text = 'tabpage2'
	$tabpage2.UseVisualStyleBackColor = $True
	#
	# tabpage3
	#
	$tabpage3.Location = '23, 4'
	$tabpage3.Name = 'tabpage3'
	$tabpage3.Padding = '3, 3, 3, 3'
	$tabpage3.Size = '602, 442'
	$tabpage3.TabIndex = 2
	$tabpage3.Text = 'tabpage3'
	$tabpage3.UseVisualStyleBackColor = $True
	#
	# tabpage4
	#
	$tabpage4.Location = '23, 4'
	$tabpage4.Name = 'tabpage4'
	$tabpage4.Padding = '3, 3, 3, 3'
	$tabpage4.Size = '602, 442'
	$tabpage4.TabIndex = 3
	$tabpage4.Text = 'tabpage4'
	$tabpage4.UseVisualStyleBackColor = $True
	#
	# tabpage5
	#
	$tabpage5.Location = '23, 4'
	$tabpage5.Name = 'tabpage5'
	$tabpage5.Padding = '3, 3, 3, 3'
	$tabpage5.Size = '602, 442'
	$tabpage5.TabIndex = 4
	$tabpage5.Text = 'tabpage5'
	$tabpage5.UseVisualStyleBackColor = $True
	#
	# tabpage6
	#
	$tabpage6.Location = '23, 4'
	$tabpage6.Name = 'tabpage6'
	$tabpage6.Padding = '3, 3, 3, 3'
	$tabpage6.Size = '602, 442'
	$tabpage6.TabIndex = 5
	$tabpage6.Text = 'tabpage6'
	$tabpage6.UseVisualStyleBackColor = $True
	#
	# tabpage7
	#
	$tabpage7.Location = '23, 4'
	$tabpage7.Name = 'tabpage7'
	$tabpage7.Padding = '3, 3, 3, 3'
	$tabpage7.Size = '602, 442'
	$tabpage7.TabIndex = 6
	$tabpage7.Text = 'tabpage7'
	$tabpage7.UseVisualStyleBackColor = $True
	#
	# tabpage8
	#
	$tabpage8.Location = '42, 4'
	$tabpage8.Name = 'tabpage8'
	$tabpage8.Padding = '3, 3, 3, 3'
	$tabpage8.Size = '583, 442'
	$tabpage8.TabIndex = 7
	$tabpage8.Text = 'tabpage8'
	$tabpage8.UseVisualStyleBackColor = $True
	#
	# tabpage9
	#
	$tabpage9.Location = '42, 4'
	$tabpage9.Name = 'tabpage9'
	$tabpage9.Padding = '3, 3, 3, 3'
	$tabpage9.Size = '583, 442'
	$tabpage9.TabIndex = 8
	$tabpage9.Text = 'tabpage9'
	$tabpage9.UseVisualStyleBackColor = $True
	#
	# tabpage10
	#
	$tabpage10.Location = '42, 4'
	$tabpage10.Name = 'tabpage10'
	$tabpage10.Padding = '3, 3, 3, 3'
	$tabpage10.Size = '583, 442'
	$tabpage10.TabIndex = 9
	$tabpage10.Text = 'tabpage10'
	$tabpage10.UseVisualStyleBackColor = $True
	#
	# tabpage11
	#
	$tabpage11.Location = '23, 4'
	$tabpage11.Name = 'tabpage11'
	$tabpage11.Padding = '3, 3, 3, 3'
	$tabpage11.Size = '602, 670'
	$tabpage11.TabIndex = 10
	$tabpage11.Text = 'tabpage11'
	$tabpage11.UseVisualStyleBackColor = $True
	$tabcontrol1.ResumeLayout()
	$form1.ResumeLayout()
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $form1.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$form1.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$form1.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $form1.ShowDialog()

} #End Function

#Call the form
Show-tabcontrol_psf | Out-Null



Dan you are my Hero :slight_smile:
Spent last 8 hours trying to work this out…

Regards
Chris

To Expand on this How would I turn the tabs & Text from Vertical to Horizontal?

If you’re talking aligned left but top to bottom…It’s complicated :slight_smile: you have to redraw the tabcontrol.

https://msdn.microsoft.com/en-us/library/ms404305(v=vs.110).aspx

If you don’t read C, there is a chrome extension by Adam Driscol that translates the msdn code examples to powershell. It’s not perfect but will give you an idea what the PS equivalent is.