ListViewItemCollection class has no constructor, so i cant create an instance. the listview in compact framework does not have SelectedItems property, so i want to create it. I want to iterate through all the items and if they are selected i want to add that item to the instance of ListViewItemCollection class. Since i can not create an instance i can not do that.

Do you have any idea?

Comments
Good question!

Have you a SelectedListViewItemsCollection class, or is it missing in a compact framework?

I think what ddanbe has led you to is what you want/need. However, I was a little confused when you said there is no constructor and you couldn't create an instance, so I had to check this myself and I found I could do it, though I cannot imagine wanting to:

ListView.ListViewItemCollection lvic = new ListView.ListViewItemCollection(new ListView());

Cheers!

And, if you pass in your listView1 object in the constructor:

ListView.ListViewItemCollection lvic = new ListView.ListViewItemCollection(listView1);

it appears to return a reference to the listView1's item collection.

Again, I recommend looking into ddanbe's suggestion using the SelectedListViewItemsCollection .

there is no ListView.SelectedListViewItemCollection in compact framework 2.0, i am trying to create one.
Any ideas?

i made a work around for this, i dont know if this is the best way possible, but it works.

private bool multiSelect = false;
		public bool MultiSelect
		{
			get
			{
				return multiSelect;
			}
			set
			{
				multiSelect = value;
				CheckBoxes = value;
				FullRowSelect = !value;
			}
		}
		private List<ListViewItem> selectedItems = new List<ListViewItem>();

		public List<ListViewItem> SelectedItems
		{
			get
			{
				selectedItems.Clear();
				if (multiSelect)
				{
					foreach (ListViewItem lvi in Items)
					{
						if (lvi.Checked)
						{
							selectedItems.Add(lvi);
						}
					}
				}
				else
				{
					foreach (ListViewItem lvi in Items)
					{
						if (lvi.Selected)
						{
							//NOTE: there can be only one selected item in this case
							selectedItems.Add(lvi);
							break;
						}
					}
				}
				return selectedItems;
			}
		}
Comments
Nice workaround.

there is no ListView.SelectedListViewItemCollection in compact framework 2.0, i am trying to create one.
Any ideas?

Try ListView.SelectedIndices Property , which is supported in the 2.0 compact framework. MSDN Reference

This question has already been answered. Start a new discussion instead.