The following works for me and takes the appropriate path depending on which component of the grid is clicked. If you set a breakpoint on the if statement and hover the mouse over ls-cHitTestInfo then you can see the Type that it is testing against.
method-id dataGridView1_MouseClick final private.
01 ls-cHitTestInfo type "System.Windows.Forms.DataGridView+HitTestInfo".
01 ls-x binary-long.
01 ls-y binary-long.
procedure division using by value sender as object e as type System.Windows.Forms.MouseEventArgs.
set ls-cHitTestInfo to self::dataGridView1::HitTest(e::X, e::Y)
if ls-cHitTestInfo::Type = type DataGridViewHitTestType::RowHeader
set dataGridView1::EditMode to type DataGridViewEditMode::EditOnKeystrokeOrF2
invoke self::dataGridView1::EndEdit
else
set self::dataGridView1::EditMode to type DataGridViewEditMode::EditOnEnter
end-if
end method.