How to: Enable Tile View in a Windows Forms ListView Control


With the tile view feature of the ListView control, you can provide a visual balance between graphical and textual information. The textual information displayed for an item in tile view is the same as the column information defined for details view. Tile view works in combination with either the grouping or insertion mark features in the ListView control.

The tile view uses a 32 x 32 pixel icon and several lines of text, as shown in the following images.

Tile View in a ListView Control
Tile view icons and text

To enable tile view, set the View property to Tile. You can adjust the size of the tiles by setting the TileSize property, and the number of text lines displayed in the tile by adjusting the Columns collection.

System_CAPS_ICON_note.jpg Note

The tile view is available only on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 when your application calls the Application.EnableVisualStyles method. On earlier operating systems, any code related to the tile view has no effect, and the ListView control displays in the large icon view. For more information, see ListView.View.

To set tile view programmatically

  1. Use the View enumeration of the ListView control.

    No code example is currently available or this language may not be supported.

The following complete code example demonstrates Tile view with tiles modified to show three lines of text. The tile size has been adjusted to prevent line-wrapping.

#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

public ref class ListViewTilingExample: public Form
   ImageList^ myImageList;

      // Initialize myListView.
      ListView^ myListView = gcnew ListView;
      myListView->Dock = DockStyle::Fill;
      myListView->View = View::Tile;
      // Initialize the tile size.
      myListView->TileSize = System::Drawing::Size( 400, 45 );
      // Initialize the item icons.
      myImageList = gcnew ImageList;
      System::Drawing::Icon^ myIcon = gcnew System::Drawing::Icon( "book.ico" );
         myImageList->Images->Add( myIcon );
         if ( myIcon )
                  delete safe_cast<IDisposable^>(myIcon);

      myImageList->ImageSize = System::Drawing::Size( 32, 32 );
      myListView->LargeImageList = myImageList;
      // Add column headers so the subitems will appear.
      array<ColumnHeader^>^temp0 = {gcnew ColumnHeader,gcnew ColumnHeader,gcnew ColumnHeader};
      myListView->Columns->AddRange( temp0 );
      // Create items and add them to myListView.
      array<String^>^temp1 = {"Programming Windows","Petzold, Charles","1998"};
      ListViewItem^ item0 = gcnew ListViewItem( temp1,0 );
      array<String^>^temp2 = {"Code: The Hidden Language of Computer Hardware and Software","Petzold, Charles","2000"};
      ListViewItem^ item1 = gcnew ListViewItem( temp2,0 );
      array<String^>^temp3 = {"Programming Windows with C#","Petzold, Charles","2001"};
      ListViewItem^ item2 = gcnew ListViewItem( temp3,0 );
      array<String^>^temp4 = {"Coding Techniques for Microsoft Visual Basic .NET","Connell, John","2001"};
      ListViewItem^ item3 = gcnew ListViewItem( temp4,0 );
      array<String^>^temp5 = {"C# for Java Developers","Jones, Allen & Freeman, Adam","2002"};
      ListViewItem^ item4 = gcnew ListViewItem( temp5,0 );
      array<String^>^temp6 = {"Microsoft .NET XML Web Services Step by Step","Jones, Allen & Freeman, Adam","2002"};
      ListViewItem^ item5 = gcnew ListViewItem( temp6,0 );
      array<ListViewItem^>^temp7 = {item0,item1,item2,item3,item4,item5};
      myListView->Items->AddRange( temp7 );
      // Initialize the form.
      this->Controls->Add( myListView );
      this->Size = System::Drawing::Size( 430, 330 );
      this->Text = "ListView Tiling Example";


   // Clean up any resources being used.
      if ( myImageList != nullptr )
         delete myImageList;

int main()
   Application::Run( gcnew ListViewTilingExample );

This example requires:

  • References to the System and System.Windows.Forms assemblies.

  • An icon file named book.ico in the same directory as the executable file.

For information about building this example from the command line for Visual Basic or Visual C#, see Building from the Command Line or Command-line Building With csc.exe. You can also build this example in Visual Studio by pasting the code into a new project. Also see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.

ListView Control
ListView Control Overview
Windows XP Features and Windows Forms Controls