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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:29:42+00:00 2026-06-13T22:29:42+00:00

I am trying to send information to a listbox to a Form from a

  • 0

I am trying to send information to a listbox to a Form from a class. Sounds simple enough. However it just won’t show anything after the method has run.

This is my Class and Method ‘Testclass’ that is being called from form one

    public void testclass()
    {
        Form1 m = new Form1();
        int tostng = "36183464";
        m.listBox1.Items.Add(tostng).ToString();
    }

in Form1 I have a listbox which has had it’s modifiers set to “Public” so not errors pop up. It will run but nothing will be entered into the listbox. This code works when everything is all in Form1.

Thank you for looking.

  • 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-13T22:29:43+00:00Added an answer on June 13, 2026 at 10:29 pm

    What you are doing is creating a new instance of the form – I presume you are trying to add items in a listbox on an existing form?

    If so do this.

    Create a function on the form with the listbox like:

    public void addItemToListBox(string item)
    {
         listBox1.Items.Add(item);
    }
    

    Then, in the class (remember to add the using System.Windows.Forms reference)

    public void doStuff()
    {
         //Change Form1 to whatever your form is called
         foreach (Form frm in Application.OpenForms)
         {
              if (frm.GetType() == typeof(Form1))
              {
                   Form1 frmTemp = (Form1)frm;
                   frmTemp.addItemToListBox("blah");
    
              }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send information from a form and a hidden email variable (from
I'm trying to send some information to our CRM from a form on our
I`m trying to send simple html page with form data to user with GET,
I am trying to send information to a server from an android phone. When
I am trying to use a dynamic select form to send information to a
I'm trying to send JSON information to jqgrid via Perl, however I'm struggling on
for one of my applications, I am trying to send/receive commands/information from my GUI
I have a socket, I'm trying to send information from the client to the
I am trying to send some information from a drop down menu when it
I am trying to send a dictionary of information from one iphone to another

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.