ListView.View 속성

정의

컨트롤에서 항목의 표시 방법을 가져오거나 설정합니다.

public:
 property System::Windows::Forms::View View { System::Windows::Forms::View get(); void set(System::Windows::Forms::View value); };
public System.Windows.Forms.View View { get; set; }
member this.View : System.Windows.Forms.View with get, set
Public Property View As View

속성 값

View 값 중 하나입니다. 기본값은 LargeIcon입니다.

예외

지정된 값이 View 값 중 하나가 아닌 경우

예제

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

이 예제 코드를 추가 하려면를 Form 폼에서 다른 메서드나 생성자의 예제에서 만든 메서드를 호출 합니다. 이 예제에서는 명명 된 이미지도 필요 MySmallImage1, MySmallImage2MyLargeImage1, 및 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

설명

View 속성을 사용하면 컨트롤이 항목을 표시하는 데 사용하는 표시 ListView 유형을 지정할 수 있습니다. 속성을 설정 View 하여 크거나 작은 아이콘이 있는 각 항목을 표시하거나 세로 목록에 항목을 표시할 수 있습니다. 가장 풍부한 옵션은 항목뿐만 아니라 각 항목에 대해 지정된 모든 하위 항목을 볼 수 있는 세부 정보 보기입니다. 각 항목은 열 머리글과 함께 각 항목이 세로로 나열되고 각 항목의 하위 항목이 열에 표시되는 그리드에 표시됩니다. 세부 정보 보기는 사용자에게 데이터베이스 정보를 표시하는 완벽한 방법입니다. Windows XP 및 Windows Server 2003을 사용하면 선택한 하위 항목 정보와 함께 큰 아이콘을 표시하여 그래픽 및 텍스트 정보의 균형을 맞추는 타일로 항목을 표시할 수도 있습니다. 타일 보기를 사용 하려면 애플리케이션 호출 해야 합니다는 Application.EnableVisualStyles 메서드. 작은 이미지 보기는 아이콘 오른쪽에 아이콘과 텍스트 정보가 있는 각 항목을 표시합니다. 큰 이미지 보기는 아이콘 아래에 아이콘과 텍스트 정보가 있는 각 항목을 표시합니다. 이미지 목록의 아이콘 크기는 또는 LargeImageList 속성에 ImageSize 대한 의 ImageList 속성으로 SmallImageList 지정됩니다.

참고

컨트롤을 사용하여 크고 작은 아이콘 보기 ListView 에 여러 이미지 목록을 사용하는 경우 이미지의 작고 큰 버전을 해당 이미지 목록의 동일한 인덱스 위치에 배치해야 합니다. 뷰 간에 전환할 때 한 목록에서 이미지의 인덱스 위치는 지정된 키 값에 관계없이 다른 목록에서 이미지를 찾는 데 사용됩니다.

컨트롤의 대부분의 속성은 ListView 다른 보기가 동작하거나 표시되는 방식에 영향을 미칩니다. 항목의 보기에 영향을 주는 일부 속성은 속성이 특정 값으로 설정된 경우에만 유용 View 하지만 다른 속성은 모든 보기에서 유용합니다. 예를 들어 및 와 같은 GridLines 속성은 속성이 로 설정된 View.Details경우에만 유용 View 하지만 MultiSelectCheckBoxes 속성은 모든 보기에서 유용합니다.FullRowSelect

다음 표에서는 일부 ListView 멤버와 해당 멤버가 유효한 보기를 보여줍니다.

ListView 멤버 View
Alignment 속성 SmallIcon 또는 LargeIcon
AutoArrange 속성 SmallIcon 또는 LargeIcon
AutoResizeColumn 메서드 Details
CheckBoxes Tile를 제외한 모든 보기
Columns 속성 Details 또는 Tile
DrawSubItem 이벤트 Details
FindItemWithText 메서드 Details, List또는 Tile
FindNearestItem 메서드 SmallIcon 또는 LargeIcon
GetItemAt 메서드 Details 또는 Tile
Groups 속성 List를 제외한 모든 보기
HeaderStyle 속성 Details
InsertionMark 속성 LargeIcon, SmallIcon또는 Tile

사용할 수는 View 다른 애플리케이션에서 데이터 뷰를 제공 하거나 해당 보기의 혜택을 활용 하려면 특정 보기를 잠글 수 속성입니다. 예를 들어 View 세부 정보 보기는 다른 보기에서 사용할 수 없는 다양한 보기 옵션을 제공하기 때문에 속성이 로 설정 View.Details 되는 경우가 많습니다.

참고

컨트롤 ListView 에 열 머리글이 지정되어 있지 않고 속성을 View.Details로 설정 View 하면 컨트롤에 항목이 ListView 표시되지 않습니다. 컨트롤에 ListView 열 머리글이 지정되어 있지 않고 속성을 View.Tile로 설정 View 하면 컨트롤에 ListView 하위 항목이 표시되지 않습니다.

타일 보기는 왼쪽에 큰 아이콘이 있고 오른쪽에 텍스트 정보가 있는 각 항목을 표시합니다. 텍스트 정보는 항목 레이블과 하위 항목으로 구성됩니다. 기본적으로 항목 레이블에 해당하는 첫 번째 하위 항목만 표시됩니다. 추가 하위 항목을 표시하려면 컬렉션에 개체를 Columns 추가 ColumnHeader 해야 합니다. 타일의 각 하위 항목은 열 머리글에 해당합니다. 표시되는 하위 항목과 하위 항목이 표시되는 순서를 제어하려면 각 항목의 ListViewItem.ListViewSubItem.Name 속성과 각 헤더에 ColumnHeader.Name 대한 속성을 설정해야 합니다. 그런 다음 컬렉션에서 Columns 헤더를 추가, 제거 및 다시 정렬하여 원하는 결과를 얻을 수 있습니다.

타일 보기에서 타일의 크기를 제어하려면 속성을 설정합니다 TileSize . 하위 항목 텍스트가 한 줄에 비해 너무 길면 줄 바꿈을 방지하는 데 유용합니다.

타일 보기의 예는 속성을 참조 TileSize 하세요.

참고

열은 세부 정보 보기에만 표시되지만 열 머리글이 없는 하위 항목은 세부 정보 보기 또는 타일 보기에 표시되지 않습니다.

바둑판식 뷰는 애플리케이션에서 호출 하는 경우 Windows XP 및 Windows Server 2003에만 사용할 수는 Application.EnableVisualStyles 메서드. 이전 운영 체제에서는 타일 보기와 관련된 모든 코드가 적용되지 않으며 컨트롤이 ListView 큰 아이콘 보기에 표시됩니다. 따라서 타일 보기에 의존하는 모든 코드가 제대로 작동하지 않을 수 있습니다.

타일 보기를 사용할 수 있는지 여부를 결정하는 코드를 포함하고 사용할 수 없는 경우 대체 기능을 제공할 수 있습니다. 예를 들어 소유자 드로잉을 사용하여 타일 보기에서 항목의 ListView 모양을 사용자 지정하는 경우 타일 보기를 지원하지 않는 운영 체제에서 실행할 때 큰 아이콘 보기에 적합한 그리기 코드를 사용할 수 있습니다.

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

적용 대상

추가 정보