'calling DataGridView.EndEdit() from picturebox click event doesn't work

I'm using a DataGridView with no binding a datasource. How can I end the datagridview editing mode by clicking on a picturebox. I've tested EndEdit() in picturebox click event, but seems it doesn't work.

    private void pictureBox1_Click(object sender, EventArgs e)
    {
        dgv.EndEdit();
    }


Solution 1:[1]

Calling EndEdit() won't end the editing mode if DataGridView.EditMode is set to EditOnEnter.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1