Edit

Share via


ListViewGroupCollection.Add Method

Definition

Adds a ListViewGroup to the collection.

Overloads

Add(ListViewGroup)

Adds the specified ListViewGroup to the collection.

Add(String, String)

Adds a new ListViewGroup to the collection using the specified values to initialize the Name and Header properties.

Add(ListViewGroup)

Source:
ListViewGroupCollection.cs
Source:
ListViewGroupCollection.cs
Source:
ListViewGroupCollection.cs

Adds the specified ListViewGroup to the collection.

public:
 int Add(System::Windows::Forms::ListViewGroup ^ group);
public int Add (System.Windows.Forms.ListViewGroup group);
member this.Add : System.Windows.Forms.ListViewGroup -> int
Public Function Add (group As ListViewGroup) As Integer

Parameters

group
ListViewGroup

The ListViewGroup to add to the collection.

Returns

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

Exceptions

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

The ListView that this collection is assigned to is in virtual mode.

Remarks

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.

See also

Applies to

Add(String, String)

Source:
ListViewGroupCollection.cs
Source:
ListViewGroupCollection.cs
Source:
ListViewGroupCollection.cs

Adds a new ListViewGroup to the collection using the specified values to initialize the Name and Header properties.

public:
 System::Windows::Forms::ListViewGroup ^ Add(System::String ^ key, System::String ^ headerText);
public System.Windows.Forms.ListViewGroup Add (string key, string headerText);
public System.Windows.Forms.ListViewGroup Add (string? key, string? headerText);
member this.Add : string * string -> System.Windows.Forms.ListViewGroup
Public Function Add (key As String, headerText As String) As ListViewGroup

Parameters

key
String

The initial value of the Name property for the new group.

headerText
String

The initial value of the Header property for the new group.

Returns

The new ListViewGroup.

Exceptions

The ListView that this collection is assigned to is in virtual mode.

Applies to