ListView::TileSize Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the size of the tiles shown in tile view.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

property Size TileSize {
	Size get();
	void set(Size value);

Property Value

Type: System.Drawing::Size

A Size that contains the new tile size.

This property controls the size of tiles when the View property is set to View::Tile. Setting this property is useful to prevent line-wrapping when subitem text is too long to be displayed on a single line.

The following code example demonstrates how to use the ListView tiling feature. In the example, the tile view displays items that represent books. Each item is shown as a tile containing an icon of a book, the title, the author, and the publication year. For the example code to work, you must include an icon file named Book.ico in the same directory as the example. To see the tile view without icons, comment out the lines relating to the ImageList object.

#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 );

.NET Framework
Available since 2.0
Return to top