views:

55

answers:

3

hi all, how can I make a ListView public? so I can access it from my first form

thank you in advance

best regards

+1  A: 

why would you want to expose the listview? Isn't it the data of the listview you are after?

You can do this with a getter method

Tarscher
+1  A: 

The best approach is to create a public readonly property to the ListView, e.g.:

public ListView MyListView {
    get {
        return myPrivateListView;
    }
}
Webleeuw
+4  A: 

By default when you drop a control on to a form the access modifier is private. You can simply go to the property screen of that control and scroll to Modifiers and set it to public or internal.

I personally dont encourage for you to expose the control from one form to the other. You should be able to easily achieve what you need to do through registering and raising events and let the form that owns the listview to handle it accordingly.

Fadrian Sudaman