Hi Chris,
Thanks very much for your feedback.
Oh, I see your concern, and have reproduced out your problem. I think you
may be confused on the static and instance field in a class of C# language.
I think you must have call this code snippet in a static method of mainForm
class. Yes?
For normal member(instance member), each instance of certain type will have
a unique copy of their own.
While for a class member(both field and method), if it is marked with
"static", it means that it belongs to type itself rather than to a specific
object. There is only one copy of static member of all the instances of
certain type. All the instances share this static member. The static member
has no visibility of instance field(Because instance field is instance
level, and belongs to a certain type instance)
To access the instance field(or method) of a type in static method, you
should create an instance of that type, then you can visit the instance
field through the new created instance.
For more information, please refer to:
http://msdn.microsoft.com/library/en...rfStaticPG.asp
For your issue, the "checkedListBox1" field is an instance field, it
belongs to a certain instance of mainForm class. So your static method can
not visit it, and a " 'CBERBU.mainForm.checkedListBox1' denotes a 'field'
where a 'class' was expected" compile-time error message will generate.
I suggest you access "checkedListBox1" in an instance method.
Why you MUST access "checkedListBox1" in a static method? Can you explain
the whole scenario to me? I think I may find a suitable design-time for you.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.