ListViewGroup 클래스

정의

ListView 컨트롤에 표시되는 항목의 그룹을 나타냅니다.

public ref class ListViewGroup sealed : System::Runtime::Serialization::ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ListViewGroupConverter))]
[System.Serializable]
public sealed class ListViewGroup : System.Runtime.Serialization.ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ListViewGroupConverter))>]
[<System.Serializable>]
type ListViewGroup = class
    interface ISerializable
Public NotInheritable Class ListViewGroup
Implements ISerializable
상속
ListViewGroup
특성
구현

예제

다음 코드 예제에서는 그룹화 기능을 사용하여 세부 정보 보기에서 ListView 하위 항목 값별로 항목을 구성하는 방법을 보여 줍니다. 이러한 형태의 그룹화 Windows 탐색기에서 사용 되는 그룹화 하는 것과 비슷합니다. 예제에서는 그룹을 동적으로 생성 됩니다. 각 하위 항목 열에 대 한 각 하위 항목 고유 값에 대해 하나의 그룹이 만들어집니다. 부모 항목 열에 대 한 각 고유 첫 문자에 대 한 하나의 그룹이 만들어집니다. 열 머리글을 클릭 하면 해당 열에 대해 만든 그룹에는 항목을 정렬 합니다. 동일한 열 머리글을 다시 클릭 하면 그룹의 순서를 반대로 바꿉니다.

#using <mscorlib.dll>
#using <System.Drawing.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Collections; 
using namespace System::Windows::Forms;

public ref class ListViewGroupsExample : public Form
{
private:
   ListView^ myListView;
   bool isRunningXPOrLater;

   // Declare a Hashtable array in which to store the groups.
   array<Hashtable^>^ groupTables;

   // Declare a variable to store the current grouping column.
   int groupColumn;

public:
   ListViewGroupsExample()
   {
      groupColumn = 0;
      // Initialize myListView.
      myListView = gcnew ListView();
      myListView->Dock = DockStyle::Fill;
      myListView->View = View::Details;
      myListView->Sorting = SortOrder::Ascending;

      // Create and initialize column headers for myListView.
      ColumnHeader^ columnHeader0 = gcnew ColumnHeader();
      columnHeader0->Text = "Title";
      columnHeader0->Width = -1;
      ColumnHeader^ columnHeader1 = gcnew ColumnHeader();
      columnHeader1->Text = "Author";
      columnHeader1->Width = -1;
      ColumnHeader^ columnHeader2 = gcnew ColumnHeader();
      columnHeader2->Text = "Year";
      columnHeader2->Width = -1;

      // Add the column headers to myListView.

      array<ColumnHeader^>^ temp0 = {columnHeader0, columnHeader1, columnHeader2};
      myListView->Columns->AddRange(temp0);

      // Add a handler for the ColumnClick event.
      myListView->ColumnClick += 
         gcnew ColumnClickEventHandler(this, &ListViewGroupsExample::myListView_ColumnClick);

      // Create items and add them to myListView.

      array<String^>^ temp1 = {"Programming Windows", "Petzold, Charles", "1998"};
      ListViewItem^ item0 = gcnew ListViewItem( temp1 );

      array<String^>^ temp2 = {"Code: The Hidden Language of Computer Hardware and Software",
         "Petzold, Charles", "2000"};
      ListViewItem^ item1 = gcnew ListViewItem( temp2 );

      array<String^>^ temp3 = {"Programming Windows with C#", "Petzold, Charles", "2001"};
      ListViewItem^ item2 = gcnew ListViewItem( temp3 );

      array<String^>^ temp4 = {"Coding Techniques for Microsoft Visual Basic .NET",
         "Connell, John", "2001"};
      ListViewItem^ item3 = gcnew ListViewItem( temp4 );

      array<String^>^ temp5 = {"C# for Java Developers", "Jones, Allen & Freeman, Adam",
         "2002"};
      ListViewItem^ item4 = gcnew ListViewItem( temp5 );

      array<String^>^ temp6 = {"Microsoft .NET XML Web Services Step by Step",
         "Jones, Allen & Freeman, Adam", "2002"};
      ListViewItem^ item5 = gcnew ListViewItem( temp6 );

      array<ListViewItem^>^ temp7 = {item0, item1, item2, item3, item4, item5};
      myListView->Items->AddRange( temp7 );

      // Determine whether Windows XP or a later 
      // operating system is present.
      isRunningXPOrLater = false;

      if (System::Environment::OSVersion->Version->Major > 5 ||
         ( System::Environment::OSVersion->Version->Major == 5 &&
         System::Environment::OSVersion->Version->Minor >= 1) )
      {
         isRunningXPOrLater = true;
      }

      if (isRunningXPOrLater)
      {
         // Create the groupsTable array and populate it with one 
         // hash table for each column.
         groupTables = gcnew array<Hashtable^>(myListView->Columns->Count);
         for (int column = 0; column < myListView->Columns->Count; column++)
         {
            // Create a hash table containing all the groups 
            // needed for a single column.
            groupTables[column] = CreateGroupsTable(column);
         }

         // Start with the groups created for the Title column.
         SetGroups(0);
      }

      // Initialize the form.
      this->Controls->Add(myListView);
      this->Size = System::Drawing::Size(550, 330);
      this->Text = "ListView Groups Example";
   }

   // Groups the items using the groups created for the clicked 
   // column.
private:
   void myListView_ColumnClick(
      Object^ /*sender*/, ColumnClickEventArgs^ e)
   {
      // Set the sort order to ascending when changing
      // column groups; otherwise, reverse the sort order.
      if ( myListView->Sorting == SortOrder::Descending || 
         ( isRunningXPOrLater && (e->Column != groupColumn) ) )
      {
         myListView->Sorting = SortOrder::Ascending;
      }
      else 
      {
         myListView->Sorting = SortOrder::Descending;
      }
      groupColumn = e->Column;

      // Set the groups to those created for the clicked column.
      if (isRunningXPOrLater)
      {
         SetGroups(e->Column);
      }
   }

   // 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]);
      }
   }

   // 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;
   }

   // Sorts ListViewGroup objects by header value.
   ref class ListViewGroupSorter : public IComparer
   {
   private:
      SortOrder order;

      // Stores the sort order.
   public:
      ListViewGroupSorter(SortOrder theOrder) 
      { 
         order = theOrder;
      }

      // Compares the groups by header value, using the saved sort
      // order to return the correct value.
      virtual int Compare(Object^ x, Object^ y)
      {
         int result = String::Compare(
            (dynamic_cast<ListViewGroup^>(x))->Header,
            (dynamic_cast<ListViewGroup^>(y))->Header
            );
         if (order == SortOrder::Ascending)
         {
            return result;
         }
         else 
         {
            return -result;
         }
      }
   };
};

[STAThread]
int main() 
{
   Application::EnableVisualStyles();
   Application::Run(gcnew ListViewGroupsExample());
}
using System;
using System.Collections; 
using System.Windows.Forms;

public class ListViewGroupsExample : Form
{
    private ListView myListView;

    // Determine whether Windows XP or a later
    // operating system is present.
    private bool isRunningXPOrLater = 
        OSFeature.Feature.IsPresent(OSFeature.Themes);

    // Declare a Hashtable array in which to store the groups.
    private Hashtable[] groupTables;

    // Declare a variable to store the current grouping column.
    int groupColumn = 0;

    public ListViewGroupsExample()
    {
        // Initialize myListView.
        myListView = new ListView();
        myListView.Dock = DockStyle.Fill;
        myListView.View = View.Details;
        myListView.Sorting = SortOrder.Ascending;

        // Create and initialize column headers for myListView.
        ColumnHeader columnHeader0 = new ColumnHeader();
        columnHeader0.Text = "Title";
        columnHeader0.Width = -1;
        ColumnHeader columnHeader1 = new ColumnHeader();
        columnHeader1.Text = "Author";
        columnHeader1.Width = -1;
        ColumnHeader columnHeader2 = new ColumnHeader();
        columnHeader2.Text = "Year";
        columnHeader2.Width = -1;

        // Add the column headers to myListView.
        myListView.Columns.AddRange(new ColumnHeader[] 
            {columnHeader0, columnHeader1, columnHeader2});

        // Add a handler for the ColumnClick event.
        myListView.ColumnClick += 
            new ColumnClickEventHandler(myListView_ColumnClick);

        // Create items and add them to myListView.
        ListViewItem item0 = new ListViewItem( new string[] 
            {"Programming Windows", 
            "Petzold, Charles", 
            "1998"} );
        ListViewItem item1 = new ListViewItem( new string[] 
            {"Code: The Hidden Language of Computer Hardware and Software", 
            "Petzold, Charles", 
            "2000"} );
        ListViewItem item2 = new ListViewItem( new string[] 
            {"Programming Windows with C#", 
            "Petzold, Charles", 
            "2001"} );
        ListViewItem item3 = new ListViewItem( new string[] 
            {"Coding Techniques for Microsoft Visual Basic .NET", 
            "Connell, John", 
            "2001"} );
        ListViewItem item4 = new ListViewItem( new string[] 
            {"C# for Java Developers", 
            "Jones, Allen & Freeman, Adam", 
            "2002"} );
        ListViewItem item5 = new ListViewItem( new string[] 
            {"Microsoft .NET XML Web Services Step by Step", 
            "Jones, Allen & Freeman, Adam", 
            "2002"} );
        myListView.Items.AddRange(
            new ListViewItem[] {item0, item1, item2, item3, item4, item5});

        if (isRunningXPOrLater)
        {
            // Create the groupsTable array and populate it with one 
            // hash table for each column.
            groupTables = new Hashtable[myListView.Columns.Count];
            for (int column = 0; column < myListView.Columns.Count; column++)
            {
                // Create a hash table containing all the groups 
                // needed for a single column.
                groupTables[column] = CreateGroupsTable(column);
            }

            // Start with the groups created for the Title column.
            SetGroups(0);
        }

        // Initialize the form.
        this.Controls.Add(myListView);
        this.Size = new System.Drawing.Size(550, 330);
        this.Text = "ListView Groups Example";
    }

    [STAThread]
    static void Main() 
    {
        Application.EnableVisualStyles();
        Application.Run(new ListViewGroupsExample());
    }

    // Groups the items using the groups created for the clicked 
    // column.
    private void myListView_ColumnClick(
        object sender, ColumnClickEventArgs e)
    {
        // Set the sort order to ascending when changing
        // column groups; otherwise, reverse the sort order.
        if ( myListView.Sorting == SortOrder.Descending || 
            ( isRunningXPOrLater && (e.Column != groupColumn) ) )
        {
            myListView.Sorting = SortOrder.Ascending;
        }
        else 
        {
            myListView.Sorting = SortOrder.Descending;
        }
        groupColumn = e.Column;

        // Set the groups to those created for the clicked column.
        if (isRunningXPOrLater)
        {
            SetGroups(e.Column);
        }
    }

    // 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];
        }
    }

    // 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;
    }

    // Sorts ListViewGroup objects by header value.
    private class ListViewGroupSorter : IComparer
    {
        private SortOrder order;

        // Stores the sort order.
        public ListViewGroupSorter(SortOrder theOrder) 
        { 
            order = theOrder;
        }

        // Compares the groups by header value, using the saved sort
        // order to return the correct value.
        public int Compare(object x, object y)
        {
            int result = String.Compare(
                ((ListViewGroup)x).Header,
                ((ListViewGroup)y).Header
            );
            if (order == SortOrder.Ascending)
            {
                return result;
            }
            else 
            {
                return -result;
            }
        }
    }
}
Imports System.Collections
Imports System.Windows.Forms

Public Class ListViewGroupsExample
    Inherits Form

    Private myListView As ListView

    ' Determine whether Windows XP or a later
    ' operating system is present.
    Private isRunningXPOrLater As Boolean = _
        OSFeature.Feature.IsPresent(OSFeature.Themes)
    
    ' Declare a Hashtable array in which to store the groups.
    Private groupTables() As Hashtable
    
    ' Declare a variable to store the current grouping column.
    Private groupColumn As Integer = 0
    
    Public Sub New()
        ' Initialize myListView.
        myListView = New ListView()
        myListView.Dock = DockStyle.Fill
        myListView.View = View.Details
        myListView.Sorting = SortOrder.Ascending
        
        ' Create and initialize column headers for myListView.
        Dim columnHeader0 As New ColumnHeader()
        columnHeader0.Text = "Title"
        columnHeader0.Width = -1
        Dim columnHeader1 As New ColumnHeader()
        columnHeader1.Text = "Author"
        columnHeader1.Width = -1
        Dim columnHeader2 As New ColumnHeader()
        columnHeader2.Text = "Year"
        columnHeader2.Width = -1
        
        ' Add the column headers to myListView.
        myListView.Columns.AddRange( New ColumnHeader() _
            {columnHeader0, columnHeader1, columnHeader2} )
        
        ' Add a handler for the ColumnClick event.
        AddHandler myListView.ColumnClick, AddressOf myListView_ColumnClick
        
        ' Create items and add them to myListView.
        Dim item0 As New ListViewItem( New String() _
            {"Programming Windows", _
            "Petzold, Charles", _
            "1998"} )
        Dim item1 As New ListViewItem( New String() _
            {"Code: The Hidden Language of Computer Hardware and Software", _
            "Petzold, Charles", _
            "2000"} )
        Dim item2 As New ListViewItem( New String() _
            {"Programming Windows with C#", _
            "Petzold, Charles", _
            "2001"} )
        Dim item3 As New ListViewItem( New String() _
            {"Coding Techniques for Microsoft Visual Basic .NET", _
            "Connell, John", _
            "2001"} )
        Dim item4 As New ListViewItem( New String() _
            {"C# for Java Developers", _
            "Jones, Allen / Freeman, Adam", _
            "2002"} )
        Dim item5 As New ListViewItem( New String() _
            {"Microsoft .NET XML Web Services Step by Step", _
            "Jones, Allen / Freeman, Adam", _
            "2002"} )
        myListView.Items.AddRange( _
            New ListViewItem() {item0, item1, item2, item3, item4, item5})
        
        If isRunningXPOrLater
            ' Create the groupsTable array and populate it with one 
            ' hash table for each column.
            groupTables = New Hashtable(myListView.Columns.Count) {}
            Dim column As Integer
            For column = 0 To myListView.Columns.Count - 1
                ' Create a hash table containing all the groups 
                ' needed for a single column.
                groupTables(column) = CreateGroupsTable(column)
            Next column
            
            ' Start with the groups created for the Title column.
            SetGroups(0)
        End If
        
        ' Initialize the form.
        Me.Controls.Add(myListView)
        Me.Size = New System.Drawing.Size(550, 330)
        Me.Text = "ListView Groups Example"
    End Sub
    
    <STAThread()> _
    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New ListViewGroupsExample())
    End Sub
    
    ' Groups the items using the groups created for the clicked 
    ' column.
    Private Sub myListView_ColumnClick( _
        sender As Object, e As ColumnClickEventArgs)

        ' Set the sort order to ascending when changing
        ' column groups; otherwise, reverse the sort order.
        If myListView.Sorting = SortOrder.Descending OrElse _
            isRunningXPOrLater And e.Column <> groupColumn Then
            myListView.Sorting = SortOrder.Ascending
        Else
            myListView.Sorting = SortOrder.Descending
        End If
        groupColumn = e.Column
        
        ' Set the groups to those created for the clicked column.
        If isRunningXPOrLater Then
            SetGroups(e.Column)
        End If
    End Sub
    
    ' 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

    ' 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

    ' Sorts ListViewGroup objects by header value.
    Private Class ListViewGroupSorter
        Implements IComparer 
        
        Private order As SortOrder
        
        ' Stores the sort order.
        Public Sub New(theOrder As SortOrder)
            order = theOrder
        End Sub
        
        ' Compares the groups by header value, using the saved sort
        ' order to return the correct value.
        Public Function Compare(x As Object, y As Object) As Integer _
            Implements IComparer.Compare
            Dim result As Integer = String.Compare( _
                CType(x, ListViewGroup).Header, _
                CType(y, ListViewGroup).Header )
            If order = SortOrder.Ascending Then
                Return result
            Else
                Return -result
            End If
        End Function 'Compare
    End Class

End Class

설명

ListView 그룹화 기능을 사용하면 논리적으로 관련된 ListView 항목의 시각적 그룹을 만들 수 있습니다. 각 그룹은 텍스트 기반 헤더 뒤에 가로줄과 해당 그룹에 할당된 항목으로 구성됩니다. 머리글 텍스트를 컨트롤의 왼쪽, 오른쪽 또는 가운데에 맞출 수 있습니다. 속성이 이외의 View.List값으로 ListView 설정되면 컨트롤에 ListView.View 할당된 모든 그룹이 표시됩니다.

ListView 그룹은 항목을 유용한 범주로 구분하여 사용자가 찾고 있는 항목을 찾는 데 도움이 됩니다. 필요한 범주를 만들 수 있습니다. 항목을 그룹화하는 일반적인 방법 중 하나는 항목을 정렬하는 방식입니다. 예를 들어 항목 이름을 사전순으로 정렬할 때 또는 세부 정보 보기에서 열 머리글을 클릭하여 목록을 정렬할 때 형식 또는 날짜와 같은 하위 항목별로 항목을 그룹화할 수 있습니다. Windows Explorer 이러한 유형의 그룹화가 사용됩니다.

그룹화 기능을 사용하려면 컨트롤의 컬렉션에 하나 이상의 ListViewGroup 개체를 ListView.GroupsListView 추가합니다. 생성자에서 그룹 머리글 텍스트 및 헤더 맞춤을 ListViewGroup 설정하거나 및 HeaderAlignment 속성을 사용하여 Header 설정합니다.

생성자에서 그룹을 지정하거나, 속성을 설정 ListViewItem.Group 하거나, 그룹의 컬렉션에 ListViewItem 항목을 직접 추가하여 그룹에 항목을 할당할 Items 수 있습니다. 모든 항목이 표시되기 전에 그룹에 할당해야 합니다. 머리글 레이블에 있는 기본 그룹의 그룹에 할당 되지 않은 모든 항목도 표시 되지 것입니다 "DefaultGroup{0}"입니다. 기본 그룹에 포함 되어 있지는 ListView.Groups 컬렉션을 변경할 수 없습니다. 모든 항목이 있는 그룹에 올바르게 추가 되었는지 확인 하는 디버깅에 주로 유용 합니다.

항목은 한 번에 하나의 그룹에만 있을 수 있습니다. 런타임에 속성을 설정 ListViewItem.Group 하거나 다른 그룹의 컬렉션에 추가하여 Items 항목이 속한 그룹을 변경할 수 있습니다. 그러면 이전 그룹에서 자동으로 제거됩니다.

참고

그룹을 사용할 때 삽입 표시 기능을 사용할 수 없습니다. 이는 그룹화 기능이 그룹 멤버 자격별로 항목을 정렬하는 반면 삽입 표시 기능은 해당 항목을 아직 정렬하지 않은 컨트롤의 끌어서 놓기 위치 변경과 ListView 함께 사용되었기 때문입니다.

참고

ListView 애플리케이션에서 호출 하는 경우 그룹은 Windows XP 및 Windows Server 2003 제품군 에서만 사용할 수는 Application.EnableVisualStyles 메서드. 이전 버전의 운영 체제 그룹 관련 모든 코드가 무시 되 고 그룹 표시 되지 않습니다. 결과적으로 그룹화 기능을 사용 하는 코드가 제대로 작동 하지 않을 수 있습니다. 그룹화 기능을 사용할 수 있는지 여부를 확인 하는 테스트를 포함할 수도 있으며 사용할 수 없을 때 대체 기능을 제공할 수 있습니다. 예를 들어, 다음 그룹으로 정렬 하는 것을 지원 하지 않는 운영 체제에서 실행 하는 경우 대체 정렬을 제공 하는 것이 좋습니다.

삽입 표시 기능은 운영 체제 테마 기능을 제공 하는 라이브러리에서 제공 됩니다. 이 라이브러리의 가용성을 확인 하려면 호출을 FeatureSupport.IsPresent(Object) 메서드 오버 로드 하 고 전달 합니다 OSFeature.Themes 값입니다.

생성자

ListViewGroup()

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

ListViewGroup(String)

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

ListViewGroup(String, HorizontalAlignment)

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

ListViewGroup(String, String)

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

속성

CollapsedState

그룹이 표시될 모습의 ListViewGroupCollapsedState를 제어합니다.

Footer

그룹 바닥글에 표시되는 텍스트입니다.

FooterAlignment

그룹 바닥글의 맞춤입니다.

Header

그룹의 머리글 텍스트를 가져오거나 설정합니다.

HeaderAlignment

그룹 머리글 텍스트의 맞춤을 가져오거나 설정합니다.

Items

이 그룹과 연결된 모든 항목이 들어 있는 컬렉션을 가져옵니다.

ListView

이 그룹이 들어 있는 ListView 컨트롤을 가져옵니다.

Name

그룹의 이름을 가져오거나 설정합니다.

Subtitle

그룹 부제목에 표시되는 텍스트입니다.

Tag

그룹에 대한 데이터가 들어 있는 개체를 가져오거나 설정합니다.

TaskLink

그룹 머리글에 표시되는 작업 링크의 이름입니다.

TitleImageIndex

그룹에 대해 표시되는 이미지의 인덱스를 가져오거나 설정합니다.

TitleImageKey

그룹에 대해 표시되는 이미지의 키를 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

명시적 인터페이스 구현

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

대상 개체를 직렬화하는 데 필요한 데이터로 SerializationInfo를 채웁니다.

적용 대상

추가 정보