output issues

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 6 years and 1 month 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
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

output issues

Post by mqh77777 »

Product, version and build: 5.5.149
32 or 64 bit version of product: 64
Operating system: Windows 10 and 7
32 or 64 bit OS: both


I have written a form that has many tabs and many buttons. Some buttons run invoke-command, some call functions etc... I have one button that will get all file type associations on a target machine. It dumps the output to Out-Gridview. It all works but when this is executed it resized the Dialog to a much smaller size. And if I remove the Out-gridview it does not resize it. Why would Out-Gridview cause this? And I would prefer not to use Out-Gridview but when I pipe the out put to the RichTextBox it is one long line and you cant read it.

  1. $buttonFindFileTypeInfo_Click = {
  2.    
  3.     $richtextbox_Output.Clear()
  4.     $richtextbox_Output.SelectionColor = 'Blue'
  5.     $PC = $PCNameBox.Text
  6.     $GetResults = Invoke-Command -ComputerName $PC -ScriptBlock {
  7.         Get-ChildItem -Path Registry::HKEY_CLASSES_ROOT | Where-Object { $_.PSChildName -like '.*' }
  8.     }
  9.    
  10.     $GetResults | Out-GridView -Title "File type assocations for $PC"
  11.     # $richtextbox_Output.AppendText($GetResults)  # how do I make this output look clean in the richtextbox?
  12.        
  13. }
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: output issues

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]

In order to display the results in a textbox you must first convert it into a string. You can also use Format-Table to change the layout of the results.

Code: Select all

$GetResults  = $GetResults  | Out-String
$richtextbox_Output.AppendText($GetResults )
David
SAPIEN Technologies, Inc.
This topic is 6 years and 1 month 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