不可调用的成员'datagirdview.Rows'不能像方法一样使用

时间:2016-12-08 09:44:52

标签: c#

在我的C#窗体中,我有一个列按钮,我想点击我得到gridview的一些特定列

以下是代码:

 private void attack_History_ViewDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            attack_History_ViewDataGridView.Rows(e.RowIndex).Cells(0);
        }

不幸的是,在Rows字中它抱怨:

Non-invocable member 'datagirdview.Rows' cannot be used like a method

1 个答案:

答案 0 :(得分:1)

如果要访问行集合中的项目,则必须使用索引器,该索引器使用方括号([])完成。同样适用于Cells

attack_History_ViewDataGridView.Rows[e.RowIndex].Cells[0];
相关问题