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

时间:2014-03-24 11:35:06

标签: c# events datagridview

我的DataGridView" todos_pacientes"上有一个CellContentDoubleClick事件。我想要做的是模拟我的按钮上的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();

 }    

1 个答案:

答案 0 :(得分:1)

尝试:

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));
}