DataGridView.row.headercell.value 仅显示 10 个字符。

huangapple go评论75阅读模式
英文:

DataGridView.row.headercell.value displays only 10 characters

问题

我有一段PowerShell代码,它使用Windows.Forms在DataGridView中显示结果,并且我想在每一行中显示索引号。但是索引值只显示从1到9,之后重置为1:

$DataGridView.Rows | % { $_.HeaderCell.Value = ($_.Index +1).ToString() }

我尝试更改为:

$DataGridView.Rows | % { $_.HeaderCell.Value = ($_.Index).ToString() }

但这没有产生结果。

英文:

I have powershell code that displays the result in DataGridView using windows.forms and I want to display the index number in each row. But the index values are only displayed from 1 to 9, and after that it is reset to 1:

DataGridView.row.headercell.value 仅显示 10 个字符。

$DataGridView.Rows | % { $_.HeaderCell.Value = ($_.Index +1).ToString() }

I tried to change

$DataGridView.Rows | % { $_.HeaderCell.Value = ($_.Index).ToString() }

But it doesn't produce results

答案1

得分: 1

@jdweng 谢谢。我调整了RowHeaders的大小。
$datagridview.RowHeadersWidthSizeMode = 'AutoSizeToDisplayedHeaders' $datagridview.AutoResizeRowHeadersWidth($datagridview.RowHeadersWidthSizeMode)
现在一切都正常。

英文:

@jdweng thx. I resized RowHeaders
$datagridview.RowHeadersWidthSizeMode = 'AutoSizeToDisplayedHeaders' $datagridview.AutoResizeRowHeadersWidth($datagridview.RowHeadersWidthSizeMode)
And now everything works.

huangapple
  • 本文由 发表于 2023年3月9日 21:34:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75685328.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定