ListViewGroupCollection.AddRange 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컬렉션에 여러 그룹을 추가합니다.
오버로드
| Name | Description |
|---|---|
| AddRange(ListViewGroup[]) |
컬렉션에 그룹 배열을 추가합니다. |
| AddRange(ListViewGroupCollection) |
컬렉션에 기존 ListViewGroupCollection 그룹을 추가합니다. |
AddRange(ListViewGroup[])
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
컬렉션에 그룹 배열을 추가합니다.
public:
void AddRange(cli::array <System::Windows::Forms::ListViewGroup ^> ^ groups);
public:
void AddRange(... cli::array <System::Windows::Forms::ListViewGroup ^> ^ groups);
public void AddRange(System.Windows.Forms.ListViewGroup[] groups);
public void AddRange(params System.Windows.Forms.ListViewGroup[] groups);
member this.AddRange : System.Windows.Forms.ListViewGroup[] -> unit
Public Sub AddRange (groups As ListViewGroup())
Public Sub AddRange (ParamArray groups As ListViewGroup())
매개 변수
- groups
- ListViewGroup[]
컬렉션에 추가할 그룹을 지정하는 형식 ListViewGroup 의 배열입니다.
예외
groups에는 이 ListViewGroupCollection그룹을 소유하는 그룹이 아닌 컨트롤에 ListView 속한 그룹이 하나 이상 ListViewItem 포함되어 있습니다.
ListView 이 컬렉션이 할당된 값은 가상 모드입니다.
예제
다음 예제에서는 세부 정보 보기에서 하위 항목 값으로 항목을 구성 ListView 하는 애플리케이션에서 메서드를 사용할 수 있는 방법을 AddRange 보여 줍니다. 이러한 형태의 그룹화는 Windows 탐색기에서 사용되는 그룹화와 유사합니다. 이 예제에서는 그룹이 동적으로 만들어집니다. 각 하위 항목 열에 대해 고유한 각 하위 항목 값에 대해 하나의 그룹이 만들어집니다. 부모 항목 열의 경우 각 고유한 초기 문자에 대해 하나의 그룹이 만들어집니다. 각 열에 대해 만든 그룹은 하위 항목 텍스트 또는 초기 문자와 함께 해시 테이블에 저장됩니다. 열 머리글을 클릭하면 열 머리글이 ListViewGroupCollection 지워집니다. 그런 다음 클릭한 열에 해당하는 해시 테이블이 검색되고 각 항목이 적절한 그룹에 할당됩니다. 마지막으로 해시 테이블에 있는 그룹의 정렬된 배열이 에 추가 ListViewGroupCollection됩니다.
전체 예제는 개요 참조 항목을 참조 ListViewGroupCollection 하세요.
// Sets myListView to the groups created for the specified column.
private:
void SetGroups(int column)
{
// Remove the current groups.
myListView->Groups->Clear();
// Retrieve the hash table corresponding to the column.
Hashtable^ groups = dynamic_cast<Hashtable^>(groupTables[column]);
// Copy the groups for the column to an array.
array<ListViewGroup^>^ groupsArray = gcnew array<ListViewGroup^>(groups->Count);
groups->Values->CopyTo(groupsArray, 0);
// Sort the groups and add them to myListView.
Array::Sort(groupsArray, gcnew ListViewGroupSorter(myListView->Sorting));
myListView->Groups->AddRange(groupsArray);
// Iterate through the items in myListView, assigning each
// one to the appropriate group.
IEnumerator^ myEnum = myListView->Items->GetEnumerator();
while (myEnum->MoveNext())
{
ListViewItem^ item = safe_cast<ListViewItem^>(myEnum->Current);
// Retrieve the subitem text corresponding to the column.
String^ subItemText = item->SubItems[column]->Text;
// For the Title column, use only the first letter.
if (column == 0)
{
subItemText = subItemText->Substring(0, 1);
}
// Assign the item to the matching group.
item->Group = dynamic_cast<ListViewGroup^>(groups[subItemText]);
}
}
// Sets myListView to the groups created for the specified column.
private void SetGroups(int column)
{
// Remove the current groups.
myListView.Groups.Clear();
// Retrieve the hash table corresponding to the column.
Hashtable groups = (Hashtable)groupTables[column];
// Copy the groups for the column to an array.
ListViewGroup[] groupsArray = new ListViewGroup[groups.Count];
groups.Values.CopyTo(groupsArray, 0);
// Sort the groups and add them to myListView.
Array.Sort(groupsArray, new ListViewGroupSorter(myListView.Sorting));
myListView.Groups.AddRange(groupsArray);
// Iterate through the items in myListView, assigning each
// one to the appropriate group.
foreach (ListViewItem item in myListView.Items)
{
// Retrieve the subitem text corresponding to the column.
string subItemText = item.SubItems[column].Text;
// For the Title column, use only the first letter.
if (column == 0)
{
subItemText = subItemText.Substring(0, 1);
}
// Assign the item to the matching group.
item.Group = (ListViewGroup)groups[subItemText];
}
}
' Sets myListView to the groups created for the specified column.
Private Sub SetGroups(column As Integer)
' Remove the current groups.
myListView.Groups.Clear()
' Retrieve the hash table corresponding to the column.
Dim groups As Hashtable = CType(groupTables(column), Hashtable)
' Copy the groups for the column to an array.
Dim groupsArray(groups.Count - 1) As ListViewGroup
groups.Values.CopyTo(groupsArray, 0)
' Sort the groups and add them to myListView.
Array.Sort(groupsArray, New ListViewGroupSorter(myListView.Sorting))
myListView.Groups.AddRange(groupsArray)
' Iterate through the items in myListView, assigning each
' one to the appropriate group.
Dim item As ListViewItem
For Each item In myListView.Items
' Retrieve the subitem text corresponding to the column.
Dim subItemText As String = item.SubItems(column).Text
' For the Title column, use only the first letter.
If column = 0 Then
subItemText = subItemText.Substring(0, 1)
End If
' Assign the item to the matching group.
item.Group = CType(groups(subItemText), ListViewGroup)
Next item
End Sub
설명
이 버전의 메서드를 AddRange 사용하여 그룹 컬렉션에 그룹 배열을 추가합니다. 이 메서드는 여러 ListViewGroup 개체를 만들고 단일 메서드 호출을 사용하여 컬렉션에 추가하려는 경우에 유용합니다. 컬렉션에 개별 그룹을 추가하려면 메서드를 Add 사용합니다.
이 메서드는 컨트롤의 항목을 ListView 그룹화 하는 여러 가지 방법을 제공 하려는 경우에 유용 합니다. 이렇게 하려면 여러 그룹 배열을 만듭니다. 그룹을 변경하려면 먼저 메서드를 Clear 사용하여 컬렉션에서 모든 그룹을 제거한 다음, 메서드를 사용하여 AddRange 다른 그룹 배열을 추가합니다.
메서드와 Add 달리 메서드에는 AddRange 추가 중인 그룹이 컬렉션에 이미 있는지 여부를 확인하는 데 사용할 수 있는 반환 값이 없습니다. 이 정보가 필요한 경우 메서드를 Contains 사용하기 전에 메서드를 AddRange 사용합니다.
추가 정보
적용 대상
AddRange(ListViewGroupCollection)
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
- Source:
- ListViewGroupCollection.cs
컬렉션에 기존 ListViewGroupCollection 그룹을 추가합니다.
public:
void AddRange(System::Windows::Forms::ListViewGroupCollection ^ groups);
public void AddRange(System.Windows.Forms.ListViewGroupCollection groups);
member this.AddRange : System.Windows.Forms.ListViewGroupCollection -> unit
Public Sub AddRange (groups As ListViewGroupCollection)
매개 변수
- groups
- ListViewGroupCollection
ListViewGroupCollection 컬렉션에 추가할 그룹을 포함하는 항목입니다.
예외
groups에는 이 ListViewGroupCollection그룹을 소유하는 그룹이 아닌 컨트롤에 ListView 속한 그룹이 하나 이상 ListViewItem 포함되어 있습니다.
ListView 이 컬렉션이 할당된 값은 가상 모드입니다.
설명
이 버전의 메서드를 AddRange 사용하여 다른 ListView 컨트롤의 ListViewGroupCollection 속성을 통해 ListView.Groups 검색하는 요소를 추가합니다.
메서드와 Add 달리 메서드에는 AddRange 추가 중인 그룹이 컬렉션에 이미 있는지 여부를 확인하는 데 사용할 수 있는 반환 값이 없습니다. 이 정보가 필요한 경우 메서드를 Contains 사용하기 전에 메서드를 AddRange 사용합니다.