Windows form Controls disappears when set to Public shared!

ramnujs

Well-known member
Joined
Jul 5, 2005
Messages
53
Location
Philippines
Programming Experience
3-5
Why is it that when windows form controls such as listview, when set to shared disappears or does not display in Form designer. Is there a way to resolve this?
 
Having a control declared as a shared variable is most unusual and suggests to me that you don't fully understand what Shared means. Can I ask why you want to declare it as Shared? Are you trying to allow it to be accessed without a reference to the form? Using a Shared variable to allow access to a control sounds like you might be just being lazy rather than making the effort to pass a reference to the containing form when you should be. I could be wrong about all that but that's my first impression.
 
I have fully understand what a shared varible is...

This is the reason why i want to declare a listview as shared.

In my UI Class I wrote a shared method SetRoomEvents(). I declared it shared because the instance of the UI class that contains listview has been created and has been loaded already. One of the button of this UI class show's and display another UI Class Instance. The moment that this new UI is closed and disposed, by clicking some button, I will call the shared procedure of UI class intance that contains the listview and new listviewitems and subitems will be added in the listview. I cannot used the listview for some operations eg(adding new listviewitems) if the listview itself is not declared shared.

if a procedure is not declared shared , that would meant that i need to explicitly create a new instace of UI class that contains the ListView......


Is there something wrong with the way i achieve the things that i want jmcilhinney? I need your Idea?

There was actualy another way that i tried and it worked but i feel that it adds more overhead to myapplication. During the activation of the UI class instance that contains the listView. I requery the records and then clear the listView and add all the records again.
 
I'm afraid I can't really understand your explanation of what you're doing, but generally speaking if you want a Shared method to access an instance then you should pass the instance as an argument.
 
Thanks!

Thank you jmcilhinney! I now have an idea on what to do.

ill just past the ListView Object as an Argument using ByRef. Then i will add a Constructor in the class.

Thank you! More Power!
 
Back
Top