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

  • Home
  • SEARCH
  • 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 8814515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:08:41+00:00 2026-06-14T04:08:41+00:00

I have a datagridview on my WinForms app which shows a list of cases

  • 0

I have a datagridview on my WinForms app which shows a list of cases the client is working on. Double clicking the ‘CaseNo’ column on the datagridview opens up a new form specific to the slected case. The double click event code is as follows:

private void dataGV_CellCoubleClick(object sender, DataGridCellEventArgs e)
{ 
    if (e.ColumnIndex == 0)
    {
        DataTable table = (DataTable)dataGV.DataSource;
        string strCaseNo = table.Rows[e.RowIndex][e.ColumnIndex].ToString();
        frmCase fC = new frmCase(strCaseNo);
        fC.MdiParent = this.MdiParent;
        fC.Show;
    }
}

The case form opens fine. However, if the user had previously double clicked a column header to apply a sort to the datagridview, then double clicking a data row opens the wrong case.

For example:

Case Name

1 Smith

2 Jones

3 Walter

Initially clicking 2 will open the frmCase for Jones.
However if you first double click the Name column to sort alphabetically as follows:

Case Name

2 Jones

1 Smith

3 Walter

Then clicking on 2 now will open the Smith case (instead of Jones as it should).

It seems that after a sort, double clicking a cell returns the value that previously occupied that row (as if the datasource has not been sorted, even though it has been sorted on the users screen).

Can someone please advise how I correct this.

  • 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-14T04:08:42+00:00Added an answer on June 14, 2026 at 4:08 am

    You are accessing the underlying table, not the grid. Try the following:

    private void dataGV_CellCoubleClick(object sender, DataGridCellEventArgs e)
    { 
        if (e.ColumnIndex == 0)
        {
            string strCaseNo = ((DataGridView)sender).Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString();
            frmCase fC = new frmCase(strCaseNo);
            fC.MdiParent = this.MdiParent;
            fC.Show;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView control in a winforms app that I'm working on. The
I'm using EntityFrameowrk 4 and WinForms. I have a DataGridView which shows 5 to
I have a DataGridView in a Winforms app that has about 1000 rows (unbound)
I have a Winforms app that has a DataGridView that is databound at runtime.
On my Winforms app, I have a primary form with a DataGridView bound to
I have a DataTable which is bound to datagridview (Winforms)... I use the following
I have a column Name Quote Price in a DataGridView winforms control. I can
i am working on a DataGridView in C# 3.5, in winforms application. I have
I have a datatable which is bound to a DataGridView in my C# winforms
I have a databound DataGridView in a Win Forms app which the user may

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.