Get access to a Windows.Form.ListBox in a static method

Hi everybody,

For some reasons I need to update a ListBox from a static function.
As this listbox is a non-static field I get a compilation error.
Could you help me fixing it ?

Thanks very much..
vinceTraceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
dont access and update the list box from the satatic function
instead return the value to be updated from the static function and then update it in a non-static function
else you will have to make the list box static as well
0
vinceTraceAuthor Commented:
Thanks.
The trouble is, I only have access to static method of the class that has the listBox..
Is there any way to use a static listBox ?
0
Anurag ThakurTechnical ManagerCommented:
i dont understand what do you mean by the following line
-->  I only have access to static method of the class that has the listBox
can you please put more light on the issue so that we can help you better
0
vinceTraceAuthor Commented:
Let's say ClassA is the class where the listBox is declared.
I want to update this listBox from ClassB, and ClassB (for some reasons) cannot access to classA current instance. So it can only access ClassA static method (if I am not wrong...)
Hope it is a bit more clear....
0
Anurag ThakurTechnical ManagerCommented:
no you cannot do this with a static listbox because what will happen to the methods in classA which are also accessing the list box - you are not going to make them static just because the list box is not accessible through ClassB

you might want to imporve your design or something because making the listbox accessible from a static method is not a solution which i wil purpose
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.