This documentation is archived and is not being maintained.

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 icons and text

Tile View in a ListView Control

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.

NoteNote:

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

  • Use the View enumeration of the ListView control.

    ListView1.View = View.Tile
    

    listView1.View = View.Tile;
    

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.

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class ListViewTilingExample
    Inherits Form

    Private myImageList As ImageList

    Public Sub New()
        ' Initialize myListView. 
        Dim myListView As New ListView()
        myListView.Dock = DockStyle.Fill
        myListView.View = View.Tile

        ' Initialize the tile size.
        myListView.TileSize = new Size(400, 45)

        ' Initialize the item icons. 
        myImageList = New ImageList()
        Dim myIcon as Icon = new Icon("book.ico")
        Try
            myImageList.Images.Add(myIcon)
        Finally
            myIcon.Dispose()
        End Try
        myIcon.Dispose()
        myImageList.ImageSize = New Size(32, 32)
        myListView.LargeImageList = myImageList

        ' Add column headers so the subitems will appear.
        myListView.Columns.AddRange(New ColumnHeader() _
            {New ColumnHeader(), New ColumnHeader(), New ColumnHeader()})

        ' Create items and add them to myListView. 
        Dim item0 As New ListViewItem( New String() _
            {"Programming Windows", _
            "Petzold, Charles", _
            "1998"}, 0 )
        Dim item1 As New ListViewItem( New String() _
            {"Code: The Hidden Language of Computer Hardware and Software", _
            "Petzold, Charles", _
            "2000"}, 0 )
        Dim item2 As New ListViewItem( New String() _
            {"Programming Windows with C#", _
            "Petzold, Charles", _
            "2001"}, 0 )
        Dim item3 As New ListViewItem( New String() _
            {"Coding Techniques for Microsoft Visual Basic .NET", _
            "Connell, John", _
            "2001"}, 0 )
        Dim item4 As New ListViewItem( New String() _
            {"C# for Java Developers", _
            "Jones, Allen / Freeman, Adam", _
            "2002"}, 0 )
        Dim item5 As New ListViewItem( New String() _
            {"Microsoft .NET XML Web Services Step by Step", _
            "Jones, Allen / Freeman, Adam", _
            "2002"}, 0 )
        myListView.Items.AddRange( _
            New ListViewItem() {item0, item1, item2, item3, item4, item5})

        ' Initialize the form. 
        Me.Controls.Add(myListView)
        Me.Size = new System.Drawing.Size(430, 330)
        Me.Text = "ListView Tiling Example" 
    End Sub 'New 

    ' Clean up any resources being used.         
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If (disposing) Then
            myImageList.Dispose()
        End If 

        MyBase.Dispose(disposing)
    End Sub

    <STAThread()> _
    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New ListViewTilingExample())
    End Sub 'Main

End Class '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 (Visual Basic) or Command-line Building With csc.exe. You can also build this example in Visual Studio by pasting the code into a new project. How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio
How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio
How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio
How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio

Show: