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 8183551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:11:49+00:00 2026-06-07T01:11:49+00:00

If I have two DataGridView items in a C# Win Forms application, and they

  • 0

If I have two DataGridView items in a C# Win Forms application, and they have the same column set at all times, how can I ensure they are always sorted the same way?

I can get a notification when one grid or the other sorts, but if I try to use that notification to sort the other grid in the same way I get a stack overflow (for obvious reasons).

I’m sure I can get around the stack overflow problem with some ugly hacks, but I figure there must be a normal way to do this. I can’t be the first one with the need to keep two DataGridViews in sync when the user’s sorting them.

  • 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-07T01:11:50+00:00Added an answer on June 7, 2026 at 1:11 am

    I get a stack overflow (for obvious reasons).

    Without sample code they might not be obvious. Do you get the Stack overflow because each update notification updates the other grid which results in a infinite loop?

    then why don’t you keep bools to track state like so:

    bool Grid1Fired = false;
    bool Grid2Fired = false;
    
    void handler_Grid1(..)
    {
        if(Grid1Fired == false && Grid2Fired == false)
        {
            Grid1Fired = true;
            SortGrids();
        }
    }
    void handler_Grid2(..)
    {
        if(Grid1Fired == false && Grid2Fired == false)
        {
            Grid2Fired = true;
            SortGrids();
        }
    }
    
    void SortGrids()
    {
        if(Grid1Fired)
        {
            // sort grid 2
        }
        else if(Grid2Fired)
        {
            // sort grid 1
        }
        Grid1Fired = false;
        Grid2Fired = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns say Main and Sub . (they can be of same
In my Windows Forms Application, basically I have two DataGridView s. I want to
I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second
I have a datagridview in my application which holds start and finish times. I
I have a windows forms application containing a datagridview control. The datagridview is populated
I have two datagridview in the same form. Is there a way to drag
I have two DataGridViews that have the same column schema (although two different DataViews
I have a Winforms DataGridView in my application. I've two checkbox columns along with
The scenario is almost the same as http://arsalantamiz.blogspot.com/2008/09/binding-datagridview-combobox-column.html . but I can't get it
In My DatagridView ,I Have Two Columns, ComboxboxColumn and TextboxColumn . I want to

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.