Export (0) Print
Expand All

ListViewItem.IndentCount Property

Note: This property is new in the .NET Framework version 2.0.

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 int IndentCount { get; set; }
/** @property */
public int get_IndentCount ()

/** @property */
public void set_IndentCount (int value)

public function get IndentCount () : int

public function set IndentCount (value : int)

Property Value

The number of small image widths by which to indent the ListViewItem.

Exception typeCondition

ArgumentOutOfRangeException

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 " demonstrates how to set the IndentCount property. To run this ", paste the following code into a Windows Form and call the InitializeIndentedListViewItems method from the form's constructor or Load event-handling method.

ListView indentedListView;

private void 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.
    ImageList list = new ImageList();
    list.Images.Add(new Bitmap(typeof(Button), "Button.bmp"));

    // SmallImageList must be set when using IndentCount.
    indentedListView.SmallImageList = list;

    ListViewItem item1 = new ListViewItem("Click", 0);
    item1.IndentCount = 1;
    ListViewItem item2 = new ListViewItem("OK", 0);
    item2.IndentCount = 2;
    ListViewItem item3 = new ListViewItem("Cancel", 0);
    item3.IndentCount = 3;
    indentedListView.Items.AddRange(new ListViewItem[] { item1, item2, item3 });

    // Add the controls to the form.
    this.Controls.Add(indentedListView);

}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft