Пример #1
0
			void AddItem (ListViewItem value)
			{
				if (list.Contains (value))
					throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "value");

				if (value.ListView != null && value.ListView != owner)
					throw new ArgumentException ("Cannot add or insert the item '" + value.Text + "' in more than one place. You must first remove it from its current location or clone it.", "value");
				if (is_main_collection)
					value.Owner = owner;
				else {
					if (value.Group != null)
						value.Group.Items.Remove (value);

					value.SetGroup (group);
				}

				list.Add (value);

				// force an update of the selected info if the new item is selected.
				if (value.Selected)
					value.SetSelectedCore (true);
			}
Пример #2
0
			public ListViewItem Insert (int index, ListViewItem item)
			{
				if (index < 0 || index > list.Count)
					throw new ArgumentOutOfRangeException ("index");

				if (owner != null && owner.VirtualMode)
					throw new InvalidOperationException ();

				if (list.Contains (item))
					throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "item");

				if (item.ListView != null && item.ListView != owner)
					throw new ArgumentException ("Cannot add or insert the item '" + item.Text + "' in more than one place. You must first remove it from its current location or clone it.", "item");

				if (is_main_collection)
					item.Owner = owner;
				else {
					if (item.Group != null)
						item.Group.Items.Remove (item);

					item.SetGroup (group);
				}

				list.Insert (index, item);

				if (is_main_collection || item.ListView != null)
					CollectionChanged (true);

				// force an update of the selected info if the new item is selected.
				if (item.Selected)
					item.SetSelectedCore (true);
				//UIA Framework event: Item Added
				OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, item));

				return item;
			}