Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Help! Explanation is long LOOK HERE

$
0
0

I've created a program in Console, but have now decided to create the program using Windows Forms. I imported all the class from the Console.

Am trying to populate the list of Form Load but am having trouble doing it, probably the way am doing it, but it seems a good way for me because I don't get mixed up in large application so am trying to make it work.

Form 1:

        private void Form1_Load(object sender, EventArgs e)
        {
            Utilities.Load();
            Utilities.DisplayList();
        }

Other Class:

        static public void DisplayList()
        {
            Form1 x = new Form1();
            foreach (var item in ListOfBooksBook)
            {
                x.listBox1.Items.Add(item.PrintItem);
            }
        }

As you can see I just want to plug in methods from other classes into Form1, but have all the work happening in the other class keeping my form1 nice and neat :)

The above code doesn't work because its not allowing me to access listbox1.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>