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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:48:40+00:00 2026-06-07T05:48:40+00:00

i have listbox that reads a xml file and gives the user the ability

  • 0

i have listbox that reads a xml file and gives the user the ability to add items from one list box to the other. I want to somehow save all item names into a xml file when a user clicks on a specific button. But instead of printing the name it prints this "System.Windows.Forms.ListBox+ObjectCollection"

I thought i could do this.

            XmlDocument doc = new XmlDocument();
            doc.Load("info.xml");
            XmlNode test = doc.CreateElement("Name");

            test.InnerText = listBox2.Items.ToString();


            doc.DocumentElement.AppendChild(test);
            doc.Save("info.xml");
  • 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-07T05:48:41+00:00Added an answer on June 7, 2026 at 5:48 am

    This will return the type of the object, not the content.

    listBox2.Items.ToString(); // System.Windows.Forms.ListBox+ObjectCollection
    

    If you want to save the entire contents of every item in your ListBox, you should iterate through every item using something like:

    foreach(var item in listBox2.Items)
    {
        // Do something with item
        Console.WriteLine(item);
    }
    

    I’d suggest using a StringBuilder to concatenate each item.

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

Sidebar

Related Questions

I have a list box that reads from a textfile to which the user
I have application reads in data from text file. Recently I realized that I
I have a listbox that users can add/remove from. To add, there's a text
I have a ListBox that gets populated with items read from a JSON response.
I have a ListBox that is bound to a list of Persons. I want
I have a listbox that displays Shipment Items (custom class) that are formatted using
I have a ListBox with items that fill TextBox es. How do I identify
I have a data bound listbox that lists names of items, I am now
I have a listbox containing all the items and a second listbox that will
I have a Listbox which I add items to it in the OnClick event.

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.