Working with Tab Control GUI Template Video
- Details
- Written by Max Trinidad
- Last Updated: 09 October 2019
- Created: 02 January 2019
- Hits: 8729
This video demonstrates how to work with the Tab Control GUI template using PowerShell Studio.
In this video you will learn how to:
- Find the Tab Control template.
- Add controls to the form.
- Change control properties in the form.
- Use Snippets code to add the code behind the form controls.
Additional Tips
Displaying output string to the Rich TextBox Control
The first time using the Rich TextBox control to display the results you will notice that the columns are misaligned. In order to display properly aligned columns, you need to go back to the Rich Textbox property in the Properties panel, select the Font property, and change it from Microsoft Sans Serif to Lucida Console.
After you change the Font property, the string output to the Rich TextBox will look properly aligned:
In the Tab Control “Processes”, in the “Filter Process” textbox, use a process name shortname with the “*” asterisk wildcard.
Create Snippet Code
As mentioned in the video, creating snippets is the best way to reuse existing code and also to create a library of reusable code for building new solutions.
Listed below is the code for the three snippets used in the sample Tab Control form:
ButtonGetFolder_Snippet ## - Open Windows GUI to select only Folders using .NET object: $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog; $FolderBrowser.RootFolder = "Desktop"; $Results = $FolderBrowser.ShowDialog(); if ($Results -eq "OK") { $location = $FolderBrowser.SelectedPath.ToString(); $textbox1.Text = $location; }
ButtonOK_Snippet ## - Code use for Tab Control form ButtonOK $Err01 = $null; $richtextbox1.Text = $null; $GetDirectories = Get-ChildItem -Directory $textbox1.Text -ErrorVariable Err01 -ErrorAction SilentlyContinue If ($Err01.Count -eq 0) { $richtextbox1.Text = $GetDirectories | Out-String -Width 1000; } else { ## - Display error notification: [void][System.Windows.Forms.MessageBox]::Show('Enter a valid folder Name!'+"`r`nError Message:`r`n$Err01", 'Invalid Folder Name'); $textbox1.Text = "Select or Enter folder name..."; };
ButtonOK2_Snippet ## - Code use for Tab Control form Button3 OK If ($textbox2.Text -eq '') { $GetProcesses = Get-process; $richtextbox2.Text = $GetProcesses | Out-String -Width 1000; } else { $GetProcesses = Get-process $textbox2.Text; $richtextbox2.Text = $GetProcesses | Out-String -Width 1000; };
Feel free to download the SampleTabControlTemplate_11162018.
Related Article
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.