GUI and Format List - Assistance

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Reddrgn2
Posts: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

GUI and Format List - Assistance

Post by Reddrgn2 »

Hi, I am creating small form to get some basic AD info based of emp #. The building of the form and the coding part is kind of the easy part. The issue I am having is the format-list part. I do not like how it looks on the form after entering emp # and clicking find button, see below for screen shot.

Image

Code: Select all

$label2.Text = Get-ADUser -Filter "EmployeeID -eq '<emp id number>'" -Properties Name, SAMAccountName, Enabled, description, title, SID, UserPrincipalName	| Format-List -Property Name, SAMAccountName, Enabled, Description, Title, UserPrincipalName, SID | Out-String
I am not sure why the coding is green colored.

I adjusted the script for this form, you would normally enter emp # in text box then click find. Clicking find does the magic and runs the script to populate the label2 textbox.

Sadly it took 20mins to build form and do the scripting, about over an hour of trying to tinker with the format-list part and end result before creating this form. I know it will take 2 mins for someone to assist me, :)
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: GUI and Format List - Assistance

Post by davidc »

You will need to use a fixed-point font, so that the text aligns correctly.

1. You can set the TextBox's Font property using the Properties panel. You can use the Courier New font.

2. Or select the TextBox in the designer and press [Ctrl + L] to apply a property set. Select Apply Console Font from list and it will change the font for all the selected controls.

3. You can also use one of preset form templates that contain a TextBox. They come preconfigured with a fixed-point font.
David
SAPIEN Technologies, Inc.
User avatar
Reddrgn2
Posts: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

Re: GUI and Format List - Assistance

Post by Reddrgn2 »

Thank you, you solved it. :) :)
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked