Export (0) Print
Expand All

ListViewItem.IndentCount Property

Gets or sets the number of small image widths by which to indent the ListViewItem.

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

Public Property IndentCount As Integer

Property Value

Type: System.Int32
The number of small image widths by which to indent the ListViewItem.


When setting IndentCount, the number specified is less than 0.

The IndentCount property can be used only when the View property of the containing ListView is set to Details, and the SmallImageList property of the ListView is set.

The following code example demonstrates how to set the IndentCount property. To run this example, paste the following code into a Windows Form and call the InitializeIndentedListViewItems method from the form's constructor or Load event-handling method.

Private indentedListView As ListView

Private Sub InitializeIndentedListViewItems() 
    indentedListView = New ListView()
    indentedListView.Width = 200

    ' View must be set to Details to use IndentCount.
    indentedListView.View = View.Details
    indentedListView.Columns.Add("Indented Items", 150)

    ' Create an image list and add an image. 
    Dim list As New ImageList()
    list.Images.Add(New Bitmap(GetType(Button), "Button.bmp"))

    ' SmallImageList must be set when using IndentCount.
    indentedListView.SmallImageList = list

    Dim item1 As New ListViewItem("Click", 0)
    item1.IndentCount = 1
    Dim item2 As New ListViewItem("OK", 0)
    item2.IndentCount = 2
    Dim item3 As New ListViewItem("Cancel", 0)
    item3.IndentCount = 3
    indentedListView.Items.AddRange(New ListViewItem() {item1, item2, item3})

    ' Add the controls to the form. 

End Sub 'InitializeIndentedListViewItems 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft