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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:19:08+00:00 2026-06-02T17:19:08+00:00

The API I’m using dosnt respond to Form_Load events. So i’d like to populate

  • 0

The API I’m using dosnt respond to Form_Load events. So i’d like to populate the CheckedListBox1 with code included in the button I use to call the dialog containing the CheckedlistBox1. Here was my first attempt.

    private void button3_Click(object sender, EventArgs e)
    {
        TextSelectorForm textSelectionForm = new TextSelectorForm();

        CheckedListBox checkedListBox1;

        string line;
        StreamReader file = new StreamReader("test.txt");
        while ((line = file.ReadLine()) != null)
        {
            TextSelectorForm.checkedListBox1.Items.Add(line);
        }
        file.Close();

        textSelectionForm.Show();
    }

Thoughts, Ideas, examples? Thank you!


I’m getting the error “Object reference not set to instance of an object”. I’m learning, slowly. Here is my code.

    public partial class Form1 : System.Windows.Forms.Form
{
    public Form1(ExternalCommandData commandData)
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        CheckedListBox.ObjectCollection data = null;

        string line;
        StreamReader file = new StreamReader(@"C:\test.txt");

        while ((line = file.ReadLine()) != null)
        {
            data.Add(line);
        }

        file.Close();

        Form2 form2 = new Form2(data);
        form2.Show();
    }
}

    public partial class Form2 : System.Windows.Forms.Form
{
    public Form2(CheckedListBox.ObjectCollection formdata)
    {
        InitializeComponent();

        if (formdata != null)
        {
            this.checkedListBox1.Items.AddRange(formdata);
        }
    }
}

(PS. What if I want to add to my question?)

  • 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-02T17:19:10+00:00Added an answer on June 2, 2026 at 5:19 pm

    I do not speak English. I am dealing with Google translator.

    If I understand your question, you want to program the following:
    1. Recover data from a text file to populate a CheckedListBox
    2. Send the recovered data to a form that will show then.

    I suggest the following:
    1. Create an object of type ListBox.ObjectCollection that stores information you need.
    2. Create a constructor in the form ListBox.ObjectCollection accept as a parameter.
    3. In the form’s constructor, assign the parameter to the ListBox.

    //CONSTRUCTOR IN TEXTSELECTORFORM
    public TextSelectorForm(ListBox.ObjectCollection dataFromOtherForm) {
        InitializeComponents();
        //Add this code after InitializeComponents();
        if (dataFromOtherForm != null) {
            this.listBoxInThisForm.AddRange(dataFromOtherForm);
        }
    }
    
    
    //CODE FOR BUTTON IN OTHER FORM
    private void button3_Click(object sender, EventArgs e) {
        //Stores the values ​​to display in the ListBox
        ListBox.ObjectCollection data = null;
    
        //Your code from retrieve data
        string line;
        StreamReader file = new StreamReader("test.txt");
        while ((line = file.ReadLine()) != null) {
            data.Add(line);
        }
        file.Close();
    
        //Form to send the data
        TextSelectorForm textSelectionForm = new TextSelectorForm(data);
        textSelectionForm.Show();
    }
    

    I hope to answer your question.

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

Sidebar

Related Questions

The API doesn't show a proper example how to use connectNulls property. I had
I've converted an api written in Java into a .net dll using IKVM, and
The API gives the code as: public function up() { $this->addColumn('table_name', 'column_name', 'string', $options);
http://api.jquery.com/index/ Is there a way to use jQuery index() method to find the index
In the Android API example FragmentTabs.java I see the following constructor code inside the
I am using gooleplaces API. I have a response in json, but the problem
The API I'm using provides a JSON payload. Part of the response has a
An api im using is providing me a date. This date is of type
Which API would I need to use to get 'n' recent tweets of a
What API or tools can I use to query the capabilities of the system

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.