C#; listbox's as one object(container)

Posted by Oyeme on Stack Overflow See other posts from Stack Overflow or by Oyeme
Published on 2010-04-30T12:03:51Z Indexed on 2010/04/30 12:07 UTC
Read the original article Hit count: 200

Filed under:

Hello,
I use Visual studio 2008
I have 5 listbox's on form,I created a new class file -called him "scaner.cs"

scaner.cs -he cannot see "listbox".

I have create an instance.
scaner Comp = new scaner(listBox2, listBox1, listBox3, listBox4, listBox5);

In scaner.cs file I use it like this.

class scaner
    {
        public ListBox ls;
        public ListBox lsE;
        public ListBox lsIVars;
        public ListBox lsNumbers;
        public ListBox lsStrings;

public scaner(ListBox ls, ListBox lsE, ListBox lsIVars, ListBox lsNumbers, ListBox lsStrings)
        {
            this.ls = ls;
            this.lsE = lsE;
            this.lsIVars = lsIVars;
            this.lsNumbers = lsNumbers;
            this.lsStrings = lsStrings;
        }
}

My question : How can i replaced this big code to more "comfortably" method.

scaner Comp = new scaner(listBox2, listBox1, listBox3, listBox4, listBox5);

IF i had more then 5 listbox's ,it will be awful. How can i acced form another class file "Listbox's" Thanks for answers.

© Stack Overflow or respective owner

Related posts about c#