ListViewItem.ListViewSubItem 클래스

정의

ListViewItem의 하위 항목을 나타냅니다.

public: ref class ListViewItem::ListViewSubItem
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ListViewSubItemConverter))]
[System.Serializable]
public class ListViewItem.ListViewSubItem
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ListViewSubItemConverter))>]
[<System.Serializable>]
type ListViewItem.ListViewSubItem = class
Public Class ListViewItem.ListViewSubItem
상속
ListViewItem.ListViewSubItem
특성

예제

다음 코드 예제를 ListView 3 개를 사용 하 여 컨트롤 ListViewItem 지정 된 개체 및 3 ListViewItem.ListViewSubItem 각 항목에 대해 지정 된 개체입니다. 예제에서는 ColumnHeader 하위 항목 세부 정보 보기에 표시할 개체입니다. 두 개의 ImageList 이미지를 제공 하 여 코드 예제의 만들어집니다 개체는 ListViewItem 개체입니다. 이러한 ImageList 개체에 추가 되는 LargeImageListSmallImageList 속성입니다. 이 예제에서는 컨트롤을 만드는 ListView 데 다음 속성을 사용합니다.

코드를 a Form 에 추가하고 폼의 생성자 또는 다른 메서드에서 예제에서 만든 메서드를 호출해야 합니다. 이 예제에서는 이름이 MySmallImage1, 및 MySmallImage2``MyLargeImage1``MyLargeImage2 드라이브 C의 루트 디렉터리에 있어야 합니다.

private:
   void CreateMyListView()
   {
      // Create a new ListView control.
      ListView^ listView1 = gcnew ListView;
      listView1->Bounds = Rectangle(Point(10,10),System::Drawing::Size( 300, 200 ));

      // Set the view to show details.
      listView1->View = View::Details;

      // Allow the user to edit item text.
      listView1->LabelEdit = true;

      // Allow the user to rearrange columns.
      listView1->AllowColumnReorder = true;

      // Display check boxes.
      listView1->CheckBoxes = true;

      // Select the item and subitems when selection is made.
      listView1->FullRowSelect = true;

      // Display grid lines.
      listView1->GridLines = true;

      // Sort the items in the list in ascending order.
      listView1->Sorting = SortOrder::Ascending;

      // Create three items and three sets of subitems for each item.
      ListViewItem^ item1 = gcnew ListViewItem( "item1",0 );

      // Place a check mark next to the item.
      item1->Checked = true;
      item1->SubItems->Add( "1" );
      item1->SubItems->Add( "2" );
      item1->SubItems->Add( "3" );
      ListViewItem^ item2 = gcnew ListViewItem( "item2",1 );
      item2->SubItems->Add( "4" );
      item2->SubItems->Add( "5" );
      item2->SubItems->Add( "6" );
      ListViewItem^ item3 = gcnew ListViewItem( "item3",0 );

      // Place a check mark next to the item.
      item3->Checked = true;
      item3->SubItems->Add( "7" );
      item3->SubItems->Add( "8" );
      item3->SubItems->Add( "9" );

      // Create columns for the items and subitems.
      // Width of -2 indicates auto-size.
      listView1->Columns->Add( "Item Column", -2, HorizontalAlignment::Left );
      listView1->Columns->Add( "Column 2", -2, HorizontalAlignment::Left );
      listView1->Columns->Add( "Column 3", -2, HorizontalAlignment::Left );
      listView1->Columns->Add( "Column 4", -2, HorizontalAlignment::Center );

      //Add the items to the ListView.
      array<ListViewItem^>^temp1 = {item1,item2,item3};
      listView1->Items->AddRange( temp1 );

      // Create two ImageList objects.
      ImageList^ imageListSmall = gcnew ImageList;
      ImageList^ imageListLarge = gcnew ImageList;

      // Initialize the ImageList objects with bitmaps.
      imageListSmall->Images->Add( Bitmap::FromFile( "C:\\MySmallImage1.bmp" ) );
      imageListSmall->Images->Add( Bitmap::FromFile( "C:\\MySmallImage2.bmp" ) );
      imageListLarge->Images->Add( Bitmap::FromFile( "C:\\MyLargeImage1.bmp" ) );
      imageListLarge->Images->Add( Bitmap::FromFile( "C:\\MyLargeImage2.bmp" ) );

      //Assign the ImageList objects to the ListView.
      listView1->LargeImageList = imageListLarge;
      listView1->SmallImageList = imageListSmall;
      
      // Add the ListView to the control collection.
      this->Controls->Add( listView1 );
   }
private void CreateMyListView()
{
    // Create a new ListView control.
    ListView listView1 = new ListView();
    listView1.Bounds = new Rectangle(new Point(10,10), new Size(300,200));

    // Set the view to show details.
    listView1.View = View.Details;
    // Allow the user to edit item text.
    listView1.LabelEdit = true;
    // Allow the user to rearrange columns.
    listView1.AllowColumnReorder = true;
    // Display check boxes.
    listView1.CheckBoxes = true;
    // Select the item and subitems when selection is made.
    listView1.FullRowSelect = true;
    // Display grid lines.
    listView1.GridLines = true;
    // Sort the items in the list in ascending order.
    listView1.Sorting = SortOrder.Ascending;
                
    // Create three items and three sets of subitems for each item.
    ListViewItem item1 = new ListViewItem("item1",0);
    // Place a check mark next to the item.
    item1.Checked = true;
    item1.SubItems.Add("1");
    item1.SubItems.Add("2");
    item1.SubItems.Add("3");
    ListViewItem item2 = new ListViewItem("item2",1);
    item2.SubItems.Add("4");
    item2.SubItems.Add("5");
    item2.SubItems.Add("6");
    ListViewItem item3 = new ListViewItem("item3",0);
    // Place a check mark next to the item.
    item3.Checked = true;
    item3.SubItems.Add("7");
    item3.SubItems.Add("8");
    item3.SubItems.Add("9");

    // Create columns for the items and subitems.
    // Width of -2 indicates auto-size.
    listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left);
    listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left);
    listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left);
    listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center);

    //Add the items to the ListView.
    listView1.Items.AddRange(new ListViewItem[]{item1,item2,item3});

    // Create two ImageList objects.
    ImageList imageListSmall = new ImageList();
    ImageList imageListLarge = new ImageList();

    // Initialize the ImageList objects with bitmaps.
    imageListSmall.Images.Add(Bitmap.FromFile("C:\\MySmallImage1.bmp"));
    imageListSmall.Images.Add(Bitmap.FromFile("C:\\MySmallImage2.bmp"));
    imageListLarge.Images.Add(Bitmap.FromFile("C:\\MyLargeImage1.bmp"));
    imageListLarge.Images.Add(Bitmap.FromFile("C:\\MyLargeImage2.bmp"));

    //Assign the ImageList objects to the ListView.
    listView1.LargeImageList = imageListLarge;
    listView1.SmallImageList = imageListSmall;

    // Add the ListView to the control collection.
    this.Controls.Add(listView1);
}
Private Sub CreateMyListView()
    ' Create a new ListView control.
    Dim listView1 As New ListView()
    listView1.Bounds = New Rectangle(New Point(10, 10), New Size(300, 200))

    ' Set the view to show details.
    listView1.View = View.Details
    ' Allow the user to edit item text.
    listView1.LabelEdit = True
    ' Allow the user to rearrange columns.
    listView1.AllowColumnReorder = True
    ' Display check boxes.
    listView1.CheckBoxes = True
    ' Select the item and subitems when selection is made.
    listView1.FullRowSelect = True
    ' Display grid lines.
    listView1.GridLines = True
    ' Sort the items in the list in ascending order.
    listView1.Sorting = SortOrder.Ascending

    ' Create three items and three sets of subitems for each item.
    Dim item1 As New ListViewItem("item1", 0)
    ' Place a check mark next to the item.
    item1.Checked = True
    item1.SubItems.Add("1")
    item1.SubItems.Add("2")
    item1.SubItems.Add("3")
    Dim item2 As New ListViewItem("item2", 1)
    item2.SubItems.Add("4")
    item2.SubItems.Add("5")
    item2.SubItems.Add("6")
    Dim item3 As New ListViewItem("item3", 0)
    ' Place a check mark next to the item.
    item3.Checked = True
    item3.SubItems.Add("7")
    item3.SubItems.Add("8")
    item3.SubItems.Add("9")

    ' Create columns for the items and subitems.
    ' Width of -2 indicates auto-size.
    listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)

    'Add the items to the ListView.
    listView1.Items.AddRange(New ListViewItem() {item1, item2, item3})

    ' Create two ImageList objects.
    Dim imageListSmall As New ImageList()
    Dim imageListLarge As New ImageList()

    ' Initialize the ImageList objects with bitmaps.
    imageListSmall.Images.Add(Bitmap.FromFile("C:\MySmallImage1.bmp"))
    imageListSmall.Images.Add(Bitmap.FromFile("C:\MySmallImage2.bmp"))
    imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLargeImage1.bmp"))
    imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLargeImage2.bmp"))

    'Assign the ImageList objects to the ListView.
    listView1.LargeImageList = imageListLarge
    listView1.SmallImageList = imageListSmall

    ' Add the ListView to the control collection.
    Me.Controls.Add(listView1)
End Sub

설명

컨트롤은 ListView 클래스에서 정의한 항목 목록을 표시합니다 ListViewItem . 각각 ListViewItem 은 클래스에 의해 정의된 하위 항목 개체를 ListViewItem.ListViewSubItem 저장할 수 있습니다. 하위 항목은 컨트롤의 ListView 속성이 View .로 설정된 Details경우 표시됩니다. 일반적으로 하위 항목에는 부모 항목과 관련된 정보가 포함됩니다. 예를 들어 컨트롤에 ListView 주문을 나타내는 항목이 표시되면 각 항목이 주문 번호를 표시할 수 있습니다. 각 항목에 하위 항목을 추가하여 주문한 제품, 주문된 항목 수량 및 주문한 항목의 총 가격과 같은 정보를 표시할 수 있습니다. 개체와 달리 ListViewItem 개체는 사용자가 직접 편집할 수 없습니다(컨트롤의 속성이 설정된 경우 LabelEdit 사용자가 개체를 ListView 편집 ListViewItemtrue수 있음ListViewItem.ListViewSubItem).

하위 항목은 사용자가 직접 편집할 수 없고 이미지를 표시할 수 없으므로 속성은 컨트롤에 표시될 때 하위 항목 텍스트의 스타일에 ListView 영향을 주는 항목으로 제한됩니다. UseItemStyleForSubItems 하위 항목이 포함된 속성 ListView 이 로 설정된 false경우 , BackColorForeColor 속성을 사용하여 Font텍스트 표시에 적용된 스타일을 변경할 수 있습니다. 일반적으로 항목과 하위 항목의 스타일은 컨트롤에서 ListView 동일하지만 특정 스타일을 ListViewItem.ListViewSubItem 변경하여 강조 표시하려면 다르게 표시하려는 항목에서 이러한 속성을 사용할 수 있습니다.

생성자

ListViewItem.ListViewSubItem()

기본값을 사용하여 ListViewItem.ListViewSubItem 클래스의 새 인스턴스를 초기화합니다.

ListViewItem.ListViewSubItem(ListViewItem, String)

지정한 소유자 및 텍스트를 사용하여 ListViewItem.ListViewSubItem 클래스의 새 인스턴스를 초기화합니다.

ListViewItem.ListViewSubItem(ListViewItem, String, Color, Color, Font)

지정한 소유자, 텍스트, 전경색, 배경색 및 글꼴 값을 사용하여 ListViewItem.ListViewSubItem 클래스의 새 인스턴스를 초기화합니다.

속성

BackColor

하위 항목 텍스트의 배경색을 가져오거나 설정합니다.

Bounds

ListViewItem.ListViewSubItem의 경계 사각형을 가져옵니다.

Font

하위 항목에 표시되는 텍스트 글꼴을 가져오거나 설정합니다.

ForeColor

하위 항목 텍스트의 전경색을 가져오거나 설정합니다.

Name

ListViewItem.ListViewSubItem의 이름을 가져오거나 설정합니다.

Tag

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

Text

하위 항목 텍스트를 가져오거나 설정합니다.

메서드

Equals(Object)

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

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

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

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

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

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

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

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

하위 항목에 적용된 스타일을 기본 글꼴 및 색에 다시 설정합니다.

ToString()

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

적용 대상

추가 정보