You could just put the code that you want to execute in a method of its own and then call this one from both event handlers. Of course you will have to specify the row index yourself in the event handler for the click event of the button though.
Like this ==>
private void DoMyFunction(int rowIndex)
{
//Do your calculation in here ok:))}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 5 || e.ColumnIndex == 6)
{
DoWork(e.RowIndex);
}
}
private void button3_Click(object sender, EventArgs e)
{
int row = 0;
DoMyFunction(row);
}
Hope that helps though...