从c#中的按钮点击调用CellContentDoubleClick事件

本文关键字:调用 CellContentDoubleClick 事件 按钮 | 更新日期: 2023-09-27 17:52:48

我有一个CellContentDoubleClick事件在我的DataGridView "todos_pacientes",我想做的是模拟我的按钮上的CellContentDoubleClick事件,我如何从我的按钮点击事件调用它?

下面是我的代码:

private void toolSt_modificar_Click(object sender, EventArgs e) 
        {
        }                    

private void Datagrid_todos_pacientes_CellContentDoubleClick(object sender,DataGridViewCellEventArgs e) 
 {
   id_paciente=Convert.ToInt32(Datagrid_todos_pacientes.Rows[e.RowIndex].Cells[0].Value.ToString());  
   datos_paciente datos = new datos_paciente();
   datos.Show();
 }    

从c#中的按钮点击调用CellContentDoubleClick事件

尝试:

private void toolSt_modificar_Click(object sender, EventArgs e) 
{
    int col = Datagrid_todos_pacientes.CurrentCell.ColumnIndex;
    int row = Datagrid_todos_pacientes.CurrentCell.RowIndex;
    Datagrid_todos_pacientes_CellContentDoubleClick(sender, new DataGridViewCellEventArgs(col, row));
}