System.Windows.Forms.ListView.ListViewItemCollection.Add C# (CSharp) Method

Add() public method

public Add ( System.Windows.Forms.ListViewItem value ) : System.Windows.Forms.ListViewItem
value System.Windows.Forms.ListViewItem
return System.Windows.Forms.ListViewItem
			public virtual ListViewItem Add (ListViewItem value)
			{
				if (owner != null && owner.VirtualMode)
					throw new InvalidOperationException ();

				AddItem (value);

				// Item is ignored until it has been added to the ListView
				if (is_main_collection || value.ListView != null)
					CollectionChanged (true);

				//UIA Framework event: Item Added
				OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, value));

				return value;
			}

Same methods

ListView.ListViewItemCollection::Add ( string text ) : System.Windows.Forms.ListViewItem
ListView.ListViewItemCollection::Add ( string text, int imageIndex ) : System.Windows.Forms.ListViewItem
ListView.ListViewItemCollection::Add ( string text, string imageKey ) : System.Windows.Forms.ListViewItem
ListView.ListViewItemCollection::Add ( string key, string text, int imageIndex ) : System.Windows.Forms.ListViewItem
ListView.ListViewItemCollection::Add ( string key, string text, string imageKey ) : System.Windows.Forms.ListViewItem

Usage Example

Example #1
0
        private ListViewGroup(SerializationInfo info, StreamingContext context)
        {
            header           = info.GetString("Header");
            name             = info.GetString("Name");
            header_alignment = (HorizontalAlignment)info.GetInt32("HeaderAlignment");
            tag = info.GetValue("Tag", typeof(object));

            int count = 0;

            try {
                count = info.GetInt32("ItemsCount");
            } catch (SerializationException e) {
                // Mono backwards compat
                try {
                    count = info.GetInt32("ListViewItemCount");
                } catch (SerializationException e2) {}
            }

            if (items == null)
            {
                items = new ListView.ListViewItemCollection(list_view_owner);
            }

            for (int i = 0; i < count; i++)
            {
                items.Add((ListViewItem)info.GetValue(string.Format("ListViewItem_{0}", i), typeof(ListViewItem)));
            }
        }
All Usage Examples Of System.Windows.Forms.ListView.ListViewItemCollection::Add