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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:12:23+00:00 2026-05-23T10:12:23+00:00

So I have a Windows Application I am working on in Visual Studio, coded

  • 0

So I have a Windows Application I am working on in Visual Studio, coded in C#, and The user enters the name of a video in a text box and then they rate things, like sound, video quality, with a NumbericUpDown. They then plus a calculate button which fills in the rating label and adds it to a listbox. Below is all the code for the class Videos, which gets all the data, and is then put into the list box. and the rating is calculated by adding all the values up, don’t think I need to show the code for that.

public class Videos
{
    // fields hold the data
    private string mName;
    private decimal mVideoScore;
    private decimal mSoundScore;
    private decimal mStoryScore;
    private string mRating;

    // Constructor
    public Videos String(string name, decimal videoScore, decimal soundScore, decimal storyScore, string rating)
    {
        mName = name;
        mVideoScore = videoScore;
        mSoundScore = soundScore;
        mStoryScore = storyScore;
        mRating = rating;
    }

    // Properties control access to the data
    public string Name
    {
        get { return mName; }
        set { mName = value;}
    }
    public decimal VideoScore
    {
        get { return mVideoScore; }
        set { mVideoScore = value;}
    }
    public decimal SoundScore
    {
        get { return mSoundScore; }
        set { mSoundScore = value; }
    }
    public decimal StoryScore
    {
        get { return mStoryScore; }
        set { mStoryScore = value; }
    }
    public string Rating
    {
        get { return mRating; }
        set { mRating = value; }
    }

    // Methods perform operations on the data
    public override string ToString()
    {
        return mName;
    }
}

So, I put into the listbox with the following code (when the user clicks the add button)

private void AddToListButton_Click(object sender, EventArgs e)
{
    // Create a new Video Class
    Videos aVideo = new Video(NameTextBox.Text, VideoRating.Value, SoundRating.Value, StoryRating.Value, RatingDataLabel.Text);
    VideoList.Items.Add(aVideo);                
}

So when they hit add, it shows up as the name of the video, but the other data is still retreivable, I have a button to retrieve and display the video they select.

So I have tried xml and saving to txt, but it just adds the video name, not the other data.

So please help me get all the data saved into an xml or txt or whatever is the appropriate file type, and then to load/open it for when the user opens the application again they can load the previously entered data.

  • 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-23T10:12:24+00:00Added an answer on May 23, 2026 at 10:12 am

    Because you are override ToString() to return the return mName.

    When add item to the list box it uses that method to get the text represented to the user.

    if you wish to serialize data to xml then:

    1- Add [Serializable()] attribute to the Video class.

    [Serializable()] 
    public class Video { ...}
    

    2- Implement a method to serialize and deserialize data to and from xml:

    public static void SerializeToXml(Video video, string outputXmlFilePath)
    {
        if (video== null)
        {
            throw new ArgumentNullException("video");
        }
    
        if (outputXmlFilePath == null)
        {
            throw new ArgumentNullException("outputXmlFilePath");
        }
    
        System.Xml.Serialization.XmlSerializer xmlSerializer =
                    new System.Xml.Serialization.XmlSerializer(video.GetType());
    
        using (StreamWriter streamWriter = new StreamWriter(outputXmlFilePath, false, System.Text.Encoding.UTF8))
        {
            xmlSerializer.Serialize(streamWriter, video);
        }
    }
    
    public static Video DeserializeFromXml(string xmlFilePath)
    {
        if (xmlFilePath == null)
        {
            throw new ArgumentNullException("xmlFilePath");
        }
    
        if (!File.Exists(xmlFilePath))
        {
            throw new FileNotFoundException("file to deserialize from xml is not exists", xmlFilePath);
        }
    
        System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Video));
    
        Video video = null;
    
        using (StreamReader streamReader = new StreamReader(xmlFilePath, Encoding.UTF8))
        {
            deserializedObject = serializer.Deserialize(streamReader);
        }
    
        return video;
    }
    

    To serialize and deserialize data from file:
    Add these two methods SerializeToXml and DeserializeFromXml to your Video calss. 2- Whenever you want to save video to file use Video.SerializeToXml(yourVideoObject, yourOutputFilePath); and to get the video back from file use Video myVideo = Video.DeserializeFromXmlFile(yourVideoFilePath);

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

Sidebar

Related Questions

I am working on creating a Windows Forms Application in C++ using Visual Studio
Greetings, I'm working in windows application using C#. I have typed-dataset called packetsDBDataSet and
I have a Windows application that uses a .NET PropertyGrid control. Is it possible
We have a windows application that contains an ActiveX WebBrowser control. As part of
I have a windows application running at the backend. I have functions in this
I have a Windows application written in C++ that occasionally evaporates. I use the
I have my Windows Application that accepts args and I use this in order
I have a Windows application that utilizes a 3rd-party tool ( FaxMan ) to
I have a Windows Workflow application that uses classes I've written for COM automation.
I have a managed Windows application that loads a managed C++ component that uses

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.