ListViewGroupCollection::Add Method (ListViewGroup^)

 

Adds the specified ListViewGroup to the collection.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
int Add(
	ListViewGroup^ group
)

Parameters

group
Type: System.Windows.Forms::ListViewGroup^

The ListViewGroup to add to the collection.

Return Value

Type: System::Int32

The index of the group within the collection, or -1 if the group is already present in the collection.

Exception Condition
ArgumentException

group contains at least one ListViewItem that belongs to a ListView control other than the one that owns this ListViewGroupCollection.

Use this method to add an existing ListViewGroup to the collection. You cannot add a ListViewGroup to the collection more than once. When you call the Add method using a ListViewGroup that is already in the collection, the addition fails and -1 is returned.

To add multiple groups to the collection, use the AddRange method.

.NET Framework
Available since 2.0
Return to top
Show: