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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:21:03+00:00 2026-05-23T22:21:03+00:00

I have 3 textboxes that have certain values in them. The values are split

  • 0

I have 3 textboxes that have certain values in them. The values are split up depending on what the strings contain using different regex.

These textboxes are in the background and the user will not see them.. However, I do want the user to see the listboxes that correspond to each textbox. That is what the code below is:

    private void listFormatHelper()
    {
        // Splits the lines in the rich text boxes
        var listOneLines = placementOneRichTextBox.Text.Split('\n');
        var listTwoLines = placementTwoRichTextBox.Text.Split('\n');
        var listUserLines = userDefinedRichTextBox.Text.Split('\n');

        // Resest the text in the listboxes
        placementOneListBox.ResetText();
        placementTwoListBox.ResetText();
        userDefinedListBox.ResetText();

        // Set the selection mode to multiple and extended.
        placementOneListBox.SelectionMode = SelectionMode.MultiExtended;
        placementTwoListBox.SelectionMode = SelectionMode.MultiExtended;
        userDefinedListBox.SelectionMode = SelectionMode.MultiExtended;

        // Shutdown the painting of the ListBox as items are added.
        placementOneListBox.BeginUpdate();
        placementTwoListBox.BeginUpdate();
        userDefinedListBox.BeginUpdate();

        // Display the items in the listbox.
        placementOneListBox.DataSource = listOneLines;
        placementTwoListBox.DataSource = listTwoLines;
        userDefinedListBox.DataSource = listUserLines;

        // Allow the ListBox to repaint and display the new items.
        placementOneListBox.EndUpdate();
        placementTwoListBox.EndUpdate();
        userDefinedListBox.EndUpdate();
    }

HOWEVER, my problem with this is that I cannot move each item in the list… What I mean is that I want to be able to have Move up, Move down,Move left, and Move right buttons. The Move up and Move down buttons will allow the user to move the selected item(s) up or down (to change the order of the items) in the specified list. The Move left and Move right buttons will allow the user to move the item on the current list to the list to the “right” or “left” of the current list.

VISUAL LAYOUT OF LISTBOXES:

placementOneListBox                userDefinedListBox                placementTwoListBox
|                 |                |                 |               |                 |
|                 |                |                 |               |                 |
|                 |                |                 |               |                 |
|                 |                |                 |               |                 |
|_________________|                |_________________|               |_________________|

and I get the error:

"Items collection cannot be modified when the DataSource property is set."

Move Up Button CODE:

    private void moveUpButton_Click(object sender, EventArgs e)
    {
        if (placementOneListBox.SelectedIndex != 0 && placementOneListBox.SelectedIndex != -1)
        {
            object item = placementOneListBox.SelectedItem;
            int index = placementOneListBox.SelectedIndex;
            placementOneListBox.Items.RemoveAt(index);
            placementOneListBox.Items.Insert(index - 1, item);
        }
    }

Move Right Button CODE:

    private void moveRightButton_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < placementTwoListBox.Items.Count; i++)
        {
            userDefinedListBox.Items.Add(placementTwoListBox.Items[i].ToString());
            placementTwoListBox.Items.Remove(placementTwoListBox.SelectedItem);
        }
    }

QUESTIONS:

  • Is there a way to go about this where I can modify the DataSource property?
  • Does anyone want to take a crack at this?
  • How can I change my listFormatHelper() function to do what I need it to do and allow the buttons to work without the error above?
  • 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-23T22:21:04+00:00Added an answer on May 23, 2026 at 10:21 pm

    You have two options:

    1. Don’t use data binding; convert the data source to a sequence of objects and populate the list(s) by adding the objects in the sequence to the Items property. Then manage the order using the Items property, as you are currently trying to do.
    2. Modify the data source itself to alter the order. How you do this depends on which data source you are using.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of textboxes that will be displayed with their existing values.
i have 2 textboxes that i am filling with StartDate, and Endate. i want
I have a few textboxes that are not required. If the user enters nothing
So basically, I have a bunch of TextBoxes that the user gets to fill
Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I
I have a series of controls, but mostly textboxes and labels that need to
I have a UserControl that consists of three TextBoxes. On a form I can
I have a login page that has several textboxes on the page, one of
I have a ASP.NET web page that contains many textboxes. Each textbox has a
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put

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.