Consider the following code:
$a = @()
$b = "" |select ho_ho,ha_ha
$b.ho_ho = "1"
$b.ha_ha = "2"
$a+=$b
$b = "" |select ho_ho,ha_ha
$b.ho_ho = "3"
$b.ha_ha = "4"
$a+=$b
$a | Format-Table -AutoSize
$a | Out-GridView
Using Format-Table, the underscores on the column headers are retained.
ho_ho ha_ha
----- -----
1 2
3 4
However, when using Out-Gridview, the underscores are automatically removed?
Does anyone know how to avoid this?
This seems to be related to the fact in WPF that the first underscore in a text prefixes the accelerator character for the control.
See this blog post for details:
So this code would display Ok in the gridview but not in the
Format-Table
outputPlease note that the escaping is only necessary on the first underscore in the string, not the others.
I think this may be regarded as a bug (since it's not actually adding any key shortcuts either), but I couldn't find any reports on http://connect.microsoft.com