使用$DataGridView1.Rows[$row.Index].Visible = $false
隐藏一些行之后,我需要计算现在可见的行数。
如果我使用$DataGridView1.Rows.GetRowCount.ToString()
我得到这个结果:
int GetRowCount(System.Windows.Forms.DataGridViewElementStates includeFilter)
因此,如果我使用$DataGridView1.Rows.GetRowCount($DataGridViewElementStates.Visible)
我希望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"."
我在做什么错了?
答案 0 :(得分:3)
如错误所示,您需要提供类型System.Windows.Forms.DataGridViewElementStates
的值:
$DataGridView1.Rows.GetRowCount([System.Windows.Forms.DataGridViewElementStates]::Visible)