【问题标题】:Count the visible rows in DataGridView using Powershell使用 Powershell 计算 DataGridView 中的可见行数
【发布时间】:2018-09-09 11:39:02
【问题描述】:

在我使用$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"."

我做错了什么?

【问题讨论】:

    标签: powershell datagridview visible rowcount


    【解决方案1】:

    如错误所示,您需要提供System.Windows.Forms.DataGridViewElementStates 类型的值:

    $DataGridView1.Rows.GetRowCount([System.Windows.Forms.DataGridViewElementStates]::Visible)
    

    【讨论】:

    猜你喜欢
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 2019-12-05
    相关资源
    最近更新 更多