我想尝试调用函数内部的事件,并且我想调用的事件是DataGridViewCellEventArgs
,但它在函数内部。但是,当我尝试下面的代码,我得到这个错误:Unable to cast object of type 'System.Windows.Forms.MouseEventArgs' to type 'System.Windows.Forms.DataGridViewCellEventArgs'.
Invalid Cast Exception was unhandled
下面是代码:
private void UpdateQuantityDataGridView(object sender, EventArgs e)
{
(...Other codes)
var _productCode = dataGridView1["Product Code", ((DataGridViewCellEventArgs)e).RowIndex].Value;
(...Other codes)
}
我拨打以上功能,当用户完成编辑数据DataGridView
,然后按“确定”按钮,上面的功能是更新用户对数据库以及DataGridView所做的任何更改。
什么是colIndex和rowIndex先生? – Kaoru