Guest Morgon Posted July 6, 2002 Posted July 6, 2002 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 Quote
*Gurus* Thinker Posted July 7, 2002 *Gurus* Posted July 7, 2002 I *think* you have to pass a reference to the lstCameras to the class object. Quote Posting Guidelines
*Gurus* Thinker Posted July 7, 2002 *Gurus* Posted July 7, 2002 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. Quote Posting Guidelines
Guest Morgon Posted July 7, 2002 Posted July 7, 2002 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. Quote
*Gurus* Thinker Posted July 8, 2002 *Gurus* Posted July 8, 2002 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. Quote Posting Guidelines
*Gurus* divil Posted July 8, 2002 *Gurus* Posted July 8, 2002 I think my last reply to the thread on the link below might help. I got so fed up of answering this question, I wrote a lengthy article on it :) http://www.visualbasicforum.com/showthread.php?s=&threadid=28005 Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.