Accessing form controls within a class?

  • Thread starter Thread starter Morgon
  • Start date Start date
M

Morgon

Guest
I have a class that's called whenever a user clicks a button on the form.. some info goes into a listbox, and everything's fine "While" the current thread is alive.. well, when things cease to be fine, I want this class to remove the item from the listbox.. however.. directly accessing lstCameras.Items.Remove() results in "Reference to a non-shared member requires an object reference" ...So my question is.. how do I either share it, or make an object reference? I tried making a public function that would remove it, but it didn't like that either... so now I'm stuck -- can anyone help? :)

-Morgon
 
It could be a parameter in the Constructor, or a parameter to a
Method, or a Property. I guess it depends on just how much of
the lifetime of the class object it would need access to the listbox.
 
Well in the class, it's doing an If statement within a While .... so during the whole class' lifetime, theoretically (am I explaining that right?) .. Basiaclly, if the condition is False from that If statement, then it needs to remove something from the listbox.
 
Sounds like the Constructor might be the way to go. Please take
my advice with a grain of salt. My .Net skills are very early in
development, and this advice is a combination of what I know
about .net classes, and what I know about OO programming with
VB in general.
 
Back
Top