0

Hey,
I am creating a usercontrol, and I would like an Items property, like in ListView.Items.
How would I do this?
Cheers,
Jacob

Edit: I'm making a static menu, that won't disappear. Would it be better to just skin a listbox? There will be events for the items.

Edited by bbman: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Geekitygeek
0

Hey there,
The thing you're asking is simple. All you have to do, in your UserControl, create some public properties that will interact with the ListView's properties:

public ListView.ListViewItemCollection Items
        {
            get
            {
                //Code for Getter   
            }

            set
            {
                //Code for Setter
            }

        }

Hope i helped :)

Edited by Alexpap: n/a

0

Hey,
I will edit the stuff like Add, Insert etc. I don't think that method will do that.
Cheers.

0

The methods and properties exposed by standard controls are no different from the methods and properties you write in code. If you want an Add method then add one to your control:

public void Add (object Item)
{
    myList.Items.Add(Item);
}

If the control you are creating is an extension of something that already exists then you can save yourself a lot of work by inheriting from it. For instance, if your menu is essentially going to be a listview with one or two custom behaviours then inherit from ListView and you will only need to add/override the behaviours unique to your control.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.