Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:49:13+00:00 2026-06-17T18:49:13+00:00

I am trying to force the DataGridViewCell to exit out of the edit mode

  • 0

I am trying to force the DataGridViewCell to exit out of the edit mode when a user clicks the row header that’s in the same row as the cell being edited. For the record, editmode is set to EditOnEnter.

So I write the following event accordingly:

private void dGV_common_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    dGV_common.EndEdit();   
} 

The above code didn’t force the cell to end the edit mode. While the below code forces the cell to exit from editmode:

    private void dGV_common_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        dGV_common.EndEdit();   
        dGV_common.CurrentCell = null;
    }

It also deselects the entire row, which is not the desired behavior when a user clicks on the RowHeader.

So, my work around has been the following:

private void dGV_customer_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    dGV_customer.EndEdit();
    dGV_customer.CurrentCell = null;
    dGV_customer.Rows[e.RowIndex].Selected = true;
}

Which works well when you select a single row header, but fails when you try to select multiple row headers by holding shift.

How can I properly handle this situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:49:15+00:00Added an answer on June 17, 2026 at 6:49 pm

    i ran into exactly the same problem this week! it appears this is a pretty well documented bug in the datagridview. i’m unsure if it’s been fixed in any later versions. checking for a row header when the grid is clicked and changing the editmode seems to work though:

    private void dataGridView_MouseClick( object sender, MouseEventArgs e ) {
      DataGridView dgv = (DataGridView)sender;
      if (dgv.HitTest(e.X, e.Y).Type == DataGridViewHitTestType.RowHeader) {
        dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
        dgv.EndEdit();
      } else {
        dgv.EditMode = DataGridViewEditMode.EditOnEnter;
      }
    }
    

    however this is still an irritating work around if you use many datagridviews throughout your application, so let me know if you discover a better solution.

    EDIT: this question seems to have a similar solution

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to force the user to download a file. For that my
I am trying to force a table row that only contains images to be
I am trying to force an iframe to the exact same height as the
I'm trying to force the landscape mode for my application because my application is
I am trying to force user to enter username and password when they run
I'm trying to force the DataForm to display an initial value that's different from
I'm trying to force a user to be redirected to the non-www website, and,
I'm trying to force the portrait mode for my application because my application is
I am trying to force a user to login once they call this update
Trying to force-download file with PHP using usual: header(Content-type: $type ); header(Content-Disposition: attachment; filename=$name);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.