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)

Public Property TileSize As Size

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.

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")
        End Try
        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.Size = new System.Drawing.Size(430, 330)
        Me.Text = "ListView Tiling Example"
    End Sub 'NewNew

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

    End Sub

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

End Class 'ListViewTilingExample 

.NET Framework
Available since 2.0
Return to top