ListViewGroup 생성자

정의

ListViewGroup 클래스의 새 인스턴스를 초기화합니다.

오버로드

ListViewGroup()

"ListViewGroup"의 기본 머리글 텍스트 및 기본 왼쪽 머리글 맞춤을 사용하여 ListViewGroup 클래스의 새 인스턴스를 초기화합니다.

ListViewGroup(String)

ListViewGroup 속성을 초기화하는 지정된 값과 기본 왼쪽 머리글 맞춤을 사용하여 Header 클래스의 새 인스턴스를 초기화합니다.

ListViewGroup(String, String)

ListViewGroupName 속성을 초기화하기 위해 지정된 값을 사용하여 Header 클래스의 새 인스턴스를 초기화합니다.

ListViewGroup(String, HorizontalAlignment)

지정된 머리글 텍스트 및 지정된 머리글 맞춤을 사용하여 ListViewGroup 클래스의 새 인스턴스를 초기화합니다.

ListViewGroup()

"ListViewGroup"의 기본 머리글 텍스트 및 기본 왼쪽 머리글 맞춤을 사용하여 ListViewGroup 클래스의 새 인스턴스를 초기화합니다.

public:
 ListViewGroup();
public ListViewGroup ();
Public Sub New ()

적용 대상

ListViewGroup(String)

ListViewGroup 속성을 초기화하는 지정된 값과 기본 왼쪽 머리글 맞춤을 사용하여 Header 클래스의 새 인스턴스를 초기화합니다.

public:
 ListViewGroup(System::String ^ header);
public ListViewGroup (string header);
public ListViewGroup (string? header);
new System.Windows.Forms.ListViewGroup : string -> System.Windows.Forms.ListViewGroup
Public Sub New (header As String)

매개 변수

header
String

그룹 머리글에 대해 표시할 텍스트입니다.

적용 대상

ListViewGroup(String, String)

ListViewGroupName 속성을 초기화하기 위해 지정된 값을 사용하여 Header 클래스의 새 인스턴스를 초기화합니다.

public:
 ListViewGroup(System::String ^ key, System::String ^ headerText);
public ListViewGroup (string key, string headerText);
public ListViewGroup (string? key, string? headerText);
new System.Windows.Forms.ListViewGroup : string * string -> System.Windows.Forms.ListViewGroup
Public Sub New (key As String, headerText As String)

매개 변수

key
String

Name 속성의 초기 값입니다.

headerText
String

Header 속성의 초기 값입니다.

적용 대상

ListViewGroup(String, HorizontalAlignment)

지정된 머리글 텍스트 및 지정된 머리글 맞춤을 사용하여 ListViewGroup 클래스의 새 인스턴스를 초기화합니다.

public:
 ListViewGroup(System::String ^ header, System::Windows::Forms::HorizontalAlignment headerAlignment);
public ListViewGroup (string header, System.Windows.Forms.HorizontalAlignment headerAlignment);
public ListViewGroup (string? header, System.Windows.Forms.HorizontalAlignment headerAlignment);
new System.Windows.Forms.ListViewGroup : string * System.Windows.Forms.HorizontalAlignment -> System.Windows.Forms.ListViewGroup
Public Sub New (header As String, headerAlignment As HorizontalAlignment)

매개 변수

header
String

그룹 머리글에 대해 표시할 텍스트입니다.

headerAlignment
HorizontalAlignment

머리글 텍스트의 맞춤을 지정하는 HorizontalAlignment 값 중 하나입니다.

예제

다음 코드 예제에서는 하는 방법을 ListViewGroup 생성자를 구성 하는 애플리케이션에서 사용할 수 ListView 항목 세부 정보 뷰에서 하위 항목 값입니다. 이러한 형태의 그룹화 Windows 탐색기에서 사용 되는 그룹화 하는 것과 비슷합니다. 예제에서는 그룹을 동적으로 생성 됩니다. 각 하위 항목 열에 대 한 각 하위 항목 고유 값에 대해 하나의 그룹이 만들어집니다. 부모 항목 열에 대 한 각 고유 첫 문자에 대 한 하나의 그룹이 만들어집니다. 각 열에 대해 만든 그룹은 초기 문자를 하위 항목 텍스트와 함께 해시 테이블에 저장 됩니다. 열 머리글을 클릭하면 이 텍스트 값이 적절한 열에 대한 항목과 그룹을 일치시킬 때 사용됩니다.

전체 예제를 참조 하세요.를 ListViewGroup 개요 항목을 참조 합니다.

   // Creates a Hashtable object with one entry for each unique
   // subitem value (or initial letter for the parent item)
   // in the specified column.
private:
   Hashtable^ CreateGroupsTable(int column)
   {
      // Create a Hashtable object.
      Hashtable^ groups = gcnew Hashtable();

      // Iterate through the items in myListView.
      IEnumerator^ myEnum1 = myListView->Items->GetEnumerator();
      while (myEnum1->MoveNext())
      {
         ListViewItem^ item = safe_cast<ListViewItem^>(myEnum1->Current);
         // Retrieve the text value for the column.
         String^ subItemText = item->SubItems[column]->Text;

         // Use the initial letter instead if it is the first column.
         if (column == 0) 
         {
            subItemText = subItemText->Substring(0, 1);
         }

         // If the groups table does not already contain a group
         // for the subItemText value, add a new group using the 
         // subItemText value for the group header and Hashtable key.
         if (!groups->Contains(subItemText))
         {
            groups->Add( subItemText, gcnew ListViewGroup(subItemText, 
               HorizontalAlignment::Left) );
         }
      }

      // Return the Hashtable object.
      return groups;
   }
// Creates a Hashtable object with one entry for each unique
// subitem value (or initial letter for the parent item)
// in the specified column.
private Hashtable CreateGroupsTable(int column)
{
    // Create a Hashtable object.
    Hashtable groups = new Hashtable();

    // Iterate through the items in myListView.
    foreach (ListViewItem item in myListView.Items)
    {
        // Retrieve the text value for the column.
        string subItemText = item.SubItems[column].Text;

        // Use the initial letter instead if it is the first column.
        if (column == 0) 
        {
            subItemText = subItemText.Substring(0, 1);
        }

        // If the groups table does not already contain a group
        // for the subItemText value, add a new group using the 
        // subItemText value for the group header and Hashtable key.
        if (!groups.Contains(subItemText))
        {
            groups.Add( subItemText, new ListViewGroup(subItemText, 
                HorizontalAlignment.Left) );
        }
    }

    // Return the Hashtable object.
    return groups;
}
' Creates a Hashtable object with one entry for each unique
' subitem value (or initial letter for the parent item)
' in the specified column.
Private Function CreateGroupsTable(column As Integer) As Hashtable
    ' Create a Hashtable object.
    Dim groups As New Hashtable()
    
    ' Iterate through the items in myListView.
    Dim item As ListViewItem
    For Each item In myListView.Items
        ' Retrieve the text value for the column.
        Dim subItemText As String = item.SubItems(column).Text
        
        ' Use the initial letter instead if it is the first column.
        If column = 0 Then
            subItemText = subItemText.Substring(0, 1)
        End If 

        ' If the groups table does not already contain a group
        ' for the subItemText value, add a new group using the 
        ' subItemText value for the group header and Hashtable key.
        If Not groups.Contains(subItemText) Then
            groups.Add( subItemText, New ListViewGroup(subItemText, _
                HorizontalAlignment.Left) )
        End If
    Next item
    
    ' Return the Hashtable object.
    Return groups
End Function 'CreateGroupsTable

적용 대상