Please help with Out-GridView formatting

Hello everybody!
Can somebody explain: is there any way to overcome such a constraint.
Since one of the string properties of an object represents a multi-line string that is more than 9 lines, the Out-GridView cmdlet outputs only first 9 lines of that property followed by three dots.
This can be easily checked via such a trivial script:

$arr = @()
$arr = 
for ($i = 1; $i -le 25; $i++) {
    $val = for ($j = 1; $j -le $i; $j++) {$j}
    $val = $val -join "`n"
    New-Object -TypeName:PSObject -Property:@{Val=$val}
}

$arr | Out-GridView

Is there any way to make the Out-GridView output all the lines independently of there amount?
Thanks in advance for any answer!!!

I dont have an answer for your specific question. I think Out-Gridview is what it is. You could however do something with Windows forms ?? I played around with google and came up with this. Might be worth playing with. If you drag the column wider, you can see all your numbers.

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(900,600)
$list = New-Object System.collections.ArrayList

$arr = for ($i = 1; $i -le 25; $i++) {
    $val = for ($j = 1; $j -le $i; $j++) {$j}
    $val = $val -join "`n"
    New-Object -TypeName:PSObject -Property:@{Val=$val}
}

$list.AddRange($arr)

$dataGridView = New-Object System.Windows.Forms.DataGridView -Property @{
    Size = New-Object System.Drawing.Size(800,400)
    ColumnHeadersVisible = $true
    DataSource = $list
}

$form.Controls.Add($dataGridView)
$form.ShowDialog()

Thanks for answering!
Yeah… WindowsForms will certainly help but it’s not convenient to script with windows forms for one-time tasks (for each one))) while piping to Out-GridView is.
I’ve thought the deal is with formatting and something like *.Format.ps1xml but as it appears it’s unfortunately not((( Seems like the point is direct in the Out-GridView’s code itself

There might be a better way. :wink: Would you like to explain what you’re actually want to do? … the whole thing … not the way you think you should go to achieve what you want. :point_up:t3:

EDIT:

Depending on the “level” of “multi-line-ness” you may try the PowerShell 7 module " ConsoleGuiTools" (GraphicalTools). There you have the cmdlet Out-ConsoleGridView. This is able to show the sample array from your question at least until the 19th line.

I’ve explained in the question at the top of the topic: I want to find a way (if exists) to make Out-GridView to output ALL the lines of a multi-line string, not only the first 9. Run my script, mentioned in the question and pay attention to the 9-th and 10-th lines of the Out-GridView output (and further). Notice the difference.
I don’t need to solve a particular (specific) task by any way. 99,99% of my tasks I solve myself in different kinds of way without any help. I don’t want to script a just-now task or code a C# app for it when I can solve it by one-line command with a number of pipelines where the last command is Out-GridView to analyze data in a convenient way. But sometimes, when it’s really matters, I have to additionally save my results in some variable to check the multi-line value in console because Out-GridView cuts off all the lines far than 9-th. It is very similar to that how different Format-* cmdlets do. So I’ve thought some formatting rules may help but seems to be not((( For now it appears to me that the only way to get what I want is to edit the de-compiled code of Out-GridView and recompile it for my use))) But of-course it’s a such a perversion)))
Just thought anybody knows some more sane way…
For " ConsoleGuiTools" – my thanks!!! But we still “sitting” on the framework and PS 5.1 (shame on us))))
Never the less thanks a lot!

1 Like

I found this interesting. Nice of M$ to provide the source.

1 Like

Wow!!! It’s really, really, really cool!!! Thank you very very much!!! Began to think to de-compile an assembly containing Out-GridView but your godsend is really awesome! Indeed “Nice of M$ to provide the source”)))