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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:03:13+00:00 2026-05-16T14:03:13+00:00

I have a List<ColumnList> ColumnListLists which has a binding source (bsLists) attached to it.

  • 0

I have a List<ColumnList> ColumnListLists which has a binding source (bsLists) attached to it. ColumnList has a List<Column> inside of it. I have a binding source attached to the current of bsLists pointing at that inner list.

Confused yet? here is some code that may help.

public class ColumnList
{
     ...
     public string Name { get; set;}
     public List<Column> ListOfColumns { get; set;}
}

public class Column
{
    ...
    public string HeaderName { get; set; }
}

public class CustContractsSetup
{
    public CustContractsSetup()
    {
        InitializeComponent();
        bsLists = new BindingSource(Properties.Settings.Default.ColumnListLists, null);
        cmbListName.DataSource = bsLists;
        cmbListName.DisplayMember = "Name";
        bsColumns = new BindingSource(bsLists, "ListOfColumns");
        lbCurrent.DataSource = bsColumns;
        lbCurrent.DisplayMember = "HeaderName";
    }
    BindingSource bsLists;
    BindingSource bsColumns;
    ListBox lbCurrent;
}

Now what I want to do is change the order of two Column‘s.

private void btnUp_Click(object sender, EventArgs e)
{
    if (lbCurrent.SelectedIndex <= 0 || lbCurrent.SelectedIndex > bsColumns.Count)
        return;
    System.Diagnostics.Debug.Print("before:");
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex - 2].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex - 1].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex + 1].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex + 2].HeaderName);
    ((ColumnList)bsLists.Current).ListOfColumns.Reverse(lbCurrent.SelectedIndex - 1, 1);
    Debug.Print("after:");
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex - 2].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex - 1].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex + 1].HeaderName);
    Debug.Print(((ColumnList)bsLists.Current).ListOfColumns[lbCurrent.SelectedIndex + 2].HeaderName);
    bsLists.ResetCurrentItem();
}

And this is the output I get

before:
Conversion Level
Conversion Programmer
Edge Required
Education Required
Target Month
after:
Conversion Level
Conversion Programmer
Edge Required
Education Required
Target Month

If things worked as they should Edge Required should have swapped with Conversion Programmer. but as you can see the before and after list are exactly the same.

What kind of mistake am I making that is keeping my list from having the order changed?

  • 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-16T14:03:13+00:00Added an answer on May 16, 2026 at 2:03 pm

    I think your basic problem is the size of the Reverse range, try:

     .Reverse(lbCurrent.SelectedIndex - 1, 2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2000 database that will not display the column list
I have a simple Android Spinner which I fill with a two column list
Possible Duplicate: nullPointerException in multi column list I have following app which fetches data
I have list of objects that contain information about which classes static EventHandler should
I want to have a two-column list of items where the right column has
I have List I want to sort Desc by Priority, which is int and
i have list of rows that user select and i want to delete them,
I have list of files which contain particular patterns, but those files have been
I have a page with this in the head <style type=text/css> #columnList { list-style-type:
I have some page elements which are meant to appear in a two column

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.