ListView.LargeImageList Propriedade

Definição

Obtém ou define o ImageList a ser usado ao exibir itens como ícones grandes no controle.Gets or sets the ImageList to use when displaying items as large icons in the control.

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

Valor da propriedade

Um ImageList que contém os ícones a serem usados quando a propriedade View estiver definida como LargeIcon.An ImageList that contains the icons to use when the View property is set to LargeIcon. O padrão é null.The default is null.

Exemplos

O exemplo de código a seguir cria um controle de ListView com três objetos ListViewItem especificados e três objetos ListViewItem.ListViewSubItem especificados para cada item.The following code example creates a ListView control with three ListViewItem objects specified and three ListViewItem.ListViewSubItem objects specified for each item. O exemplo também cria ColumnHeader objetos para exibir os subitens na exibição de detalhes.The example also creates ColumnHeader objects to display the subitems in details view. Dois objetos ImageList também são criados no exemplo de código para fornecer imagens para os objetos ListViewItem.Two ImageList objects are also created in the code example to provide images for the ListViewItem objects. Esses objetos ImageList são adicionados às propriedades LargeImageList e SmallImageList.These ImageList objects are added to the LargeImageList and SmallImageList properties. O exemplo usa as propriedades a seguir na criação do controle de ListView.The example uses the following properties in creating the ListView control.

Este exemplo requer que você tenha adicionado o código a um Form e chame o método criado no exemplo do construtor ou de outro método no formulário.This example requires that you have added the code to a Form and call the method created in the example from the constructor or another method on the form. O exemplo também exige que as imagens nomeadas MySmallImage1, MySmallImage2, MyLargeImage1e MyLargeImage2 estejam localizadas no diretório raiz da unidade C.The example also requires that images named MySmallImage1, MySmallImage2, MyLargeImage1, and MyLargeImage2 are located in the root directory of drive 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

Comentários

A propriedade LargeImageList permite especificar um objeto ImageList que contém ícones a serem usados ao exibir itens com ícones grandes (quando a propriedade View é definida como LargeIcon).The LargeImageList property allows you to specify an ImageList object that contains icons to use when displaying items with large icons (when the View property is set to LargeIcon). O controle de ListView pode aceitar qualquer formato de gráfico ao qual o controle de ImageList dá suporte ao exibir ícones.The ListView control can accept any graphics format that the ImageList control supports when displaying icons. O controle de ListView não está limitado a arquivos. ico.The ListView control is not limited to .ico files. Quando um ImageList é atribuído à propriedade LargeImageList, você pode definir a propriedade ImageIndex de cada ListViewItem no controle ListView para a posição do índice da imagem apropriada na ImageList.Once an ImageList is assigned to the LargeImageList property, you can set the ImageIndex property of each ListViewItem in the ListView control to the index position of the appropriate image in the ImageList. O tamanho dos ícones para o LargeImageList é especificado pelo ImageSize.The size of the icons for the LargeImageList is specified by the ImageSize.

Como apenas um índice pode ser especificado para a propriedade ListViewItem.ImageIndex, os objetos ImageList especificados nas propriedades LargeImageList e SmallImageList devem ter as mesmas posições de índice para as imagens a serem exibidas.Because only one index can be specified for the ListViewItem.ImageIndex property, the ImageList objects specified in the LargeImageList and SmallImageList properties should have the same index positions for the images to display. Por exemplo, se a propriedade ImageIndex de uma ListViewItem for definida como 0, as imagens a serem usadas para ícones pequenos e grandes devem estar na mesma posição de índice nos objetos ImageList especificados nas propriedades LargeImageList e SmallImageList.For example, if the ImageIndex property of a ListViewItem is set to 0, the images to use for both small and large icons should be at the same index position in the ImageList objects specified in the LargeImageList and SmallImageList properties.

Observação

Quando as imagens forem especificadas com chaves, você ainda precisará posicionar versões pequenas e grandes da imagem no mesmo local de índice em suas respectivas listas de imagens.When the images are specified with keys, you still need to place small and large versions of the image at the same index location in their respective image lists. Ao alternar entre exibições, o local do índice da imagem em uma lista é usado para localizar a imagem na outra lista, independentemente do valor de chave especificado.When switching between views, the index location of the image in one list is used to locate the image in the other list, regardless of the key value specified.

Para definir o ImageList a ser usado ao exibir itens com ícones pequenos (todos os modos de exibição diferentes de LargeIcon), use a propriedade SmallImageList.To set the ImageList to use when displaying items with small icons (all view modes other than LargeIcon), use the SmallImageList property. Se você quiser usar imagens para exibir o estado do item, use a propriedade StateImageList.If you want to use images to display item state, use the StateImageList property.

Aplica-se a

Veja também