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

The Archive Base Latest Questions

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

i have a new question. i have a code to load a list from

  • 0

i have a new question. i have a code to load a list from binary file, i think i did it right but i need to make each variable show in its own text box. this is the ting i cannot find out how to do. can anyone help me or point me to where i can find the information?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace test
 {

public partial class Form1 : Form
{
    [Serializable]
    public class ore
    {
        public float Titan;
        public float Eperton;
    }
    ore b1 = null;
    ore b2 = null;



    public Form1()
    {
        InitializeComponent();

        b2 = new ore();
        b1 = new ore();
    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {

        float tempFloat;


        if (float.TryParse(textBox1.Text, out tempFloat))
        {
            b1.Titan = tempFloat;
        }
        else
            MessageBox.Show("uh oh");



    }


    private void textBox2_TextChanged(object sender, EventArgs e)
    {
        float tempFloat;
        if (float.TryParse(textBox1.Text, out tempFloat))
        {
            b2.Eperton = tempFloat;
        }
        else
            MessageBox.Show("uh oh");


    }


    private void button1_Click(object sender, EventArgs e)
    {
        List<ore> oreData = new List<ore>();
        oreData.Add(b1);
        oreData.Add(b2);

        FileStream fs = new FileStream("ore.dat", FileMode.Create);
        BinaryFormatter bf = new BinaryFormatter();
        bf.Serialize(fs, oreData);
        fs.Close();
    }

    private void textBox3_TextChanged(object sender, EventArgs e)
    {

    }

    private void textBox4_TextChanged(object sender, EventArgs e)
    {

    }

    List<ore> books = new List<ore>();
    private void button2_Click(object sender, EventArgs e)
    {
        FileStream fs = new FileStream("ore.dat", FileMode.Open);
        BinaryFormatter bf = new BinaryFormatter();
        List<ore> books = (List<ore>)bf.Deserialize(fs);
        fs.Close();

        if (books.Count > 1)
        {
            textBox3.Text = books[0];//update the first text
            textBox4.Text = books[1];//update the second text
        }
    }
}

}

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

    Windows Forms:

    1- Define your List books at class level so you can use it in another methods if needed..

    2-

    public clas MyForm : Form
    {
        List<ore> books = new List<ore>();//define at the class scope
    
        private void button2_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream("ore.dat", FileMode.Open);
            BinaryFormatter bf = new BinaryFormatter();
            books = (List<ore>)bf.Deserialize(fs);
            fs.Close();
    
            if (books.Count > 1)
            {
                textBox3.Text = books[0];//update the first text
                textBox4.Text = books[1];//update the second text
            }
        } 
    }
    

    If you need collection of list boxes to be added and removed whenever a book list changes then this is another story… write a comment or update your question…

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

Sidebar

Related Questions

I made a similar question a few days ago, but now I have new
Simple question. I have a new list and an old list. In Java is
Following on from my previous question [link text][1] , I have a new problem.
I have read some topic regarding with my question but there code doesn't work
Hi i have a simple question. here is my code: XmlDocument xmlData = new
I posted a similar RBL question but I have a new issue arising so
I have been asked to post a new question about how to correctly sort
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I am new to C and i have this question. why does the following
I'm new to postgreSQL and I have a simple question: I'm trying to create

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.