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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:34:04+00:00 2026-05-13T12:34:04+00:00

This will be a stupid question but I have a datagridview with a BindingSource

  • 0

This will be a stupid question but I have a datagridview with a BindingSource as datasource.

The bindingSources.Datasource is a own BindingList with sort support. All this works.

But when a record will be inserted in the sorted list, then it will placed at the end of the datagridiview. After a refresh (example with the mouse click), the record will be placed on the right place.

So, I think that I forget something to implementat or call to ensure that the inserted record will be displayed directy on the right place of the datagridview.

Who can help me with a tip.

Thanks.

  • 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-05-13T12:34:05+00:00Added an answer on May 13, 2026 at 12:34 pm

    I have this working with the following code.

    Please excuse the rough code – I’m just showing the key pieces, but I can provide a more complete example if you need.

    I have a SortableBindingList _names which is bound to my DataGridView. Then on my form I have a button, with a new names added in the Click even handler. This is working fine to add the name kevin between joe and pete.

    private SortableBindingList<Names> _names;
    
    public Form1()
    {
        InitializeComponent();
    
        _names = new SortableBindingList<Names>();
        _names.Add(new Names() { Name = "joe" });
        _names.Add(new Names() { Name = "pete" });
    
        DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
        col1.DataPropertyName = "Name";
    
        dataGridView1.Columns.Add(col1);
    
        dataGridView1.DataSource = _names;            
    }
    
    private void button1_Click(object sender, EventArgs e)
    {             
       _names.Add(new Names(){Name = "kevin"});
       dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Descending);
    } 
    
    
    public class Names
    {
        public string Name { get; set; }
    }
    

    So the key thing is that I sort my dataGridView after adding to the list.

    I could have also provided an IComparer in my .Sort() call – the default comparer is just comparing on .ToString()

    Interestingly, in my example, the following also works, when inserting the item:

    private void button1_Click(object sender, EventArgs e)
    {             
       //_names.Add(new Names(){Name = "kevin"});
       _names.Insert(1, new Names() { Name = "kevin" });
       // dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Descending);
    }
    

    Simply inserting the item at the right place is enough to make the grid display the list sorted correctly. I’m using the same SortableBindingList as you, the one shown at MartinWilley.com.

    Could your problem be that you are adding rather then inserting?

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

Sidebar

Ask A Question

Stats

  • Questions 270k
  • Answers 270k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is a very broad question. I'd start with Apple's… May 13, 2026 at 1:25 pm
  • Editorial Team
    Editorial Team added an answer Here's how I solved it in the end. Generate an… May 13, 2026 at 1:25 pm
  • Editorial Team
    Editorial Team added an answer You should declare your array as a property. Synthesize it… May 13, 2026 at 1:25 pm

Related Questions

I have a timer job which has been deployed to a server with multiple
Ok...I am new to rails so this may be a stupid question but need
I would like a bit more clarification on the toxi method of storing tags
I am very new to Spring and I have been given some basic instructions
this is a really stupid question but I have a deadline and I'm very

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.