[英]Count the visible rows in DataGridView using Powershell
After I've used $DataGridView1.Rows[$row.Index].Visible = $false
to hide some rows, I need to count how many are visible now. 在我使用
$DataGridView1.Rows[$row.Index].Visible = $false
隐藏一些行之后,我需要计算现在可见的行数。
If I use $DataGridView1.Rows.GetRowCount.ToString()
如果我使用
$DataGridView1.Rows.GetRowCount.ToString()
I get this result: 我得到这个结果:
int GetRowCount(System.Windows.Forms.DataGridViewElementStates includeFilter)
So, if I use $DataGridView1.Rows.GetRowCount($DataGridViewElementStates.Visible)
因此,如果我使用
$DataGridView1.Rows.GetRowCount($DataGridViewElementStates.Visible)
I would expect a number of the visible rows in my DataGridView, but it returns an exception: 我希望在DataGridView中有许多可见行,但是会返回一个异常:
Cannot convert argument "includeFilter", with value: "", for "GetRowCount"
to type "System.Windows.Forms.DataGridViewElementStates": "Cannot convert null
to type "System.Windows.Forms.DataGridViewElementStates" due to enumeration
values that are not valid. Specify one of the following enumeration values and
try again. The possible enumeration values are
"None,Displayed,Frozen,ReadOnly,Resizable,ResizableSet,Selected,Visible"."
What am I doing wrong? 我究竟做错了什么?
如错误所示,您需要提供System.Windows.Forms.DataGridViewElementStates
类型的值:
$DataGridView1.Rows.GetRowCount([System.Windows.Forms.DataGridViewElementStates]::Visible)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.