Export (0) Print
Expand All

TreeView.Indent Property

Gets or sets the distance to indent each child tree node level.

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

member Indent : int with get, set

Property Value

Type: System.Int32
The distance, in pixels, to indent each child tree node level. The default value is 19.

ExceptionCondition
ArgumentOutOfRangeException

The assigned value is less than 0 (see Remarks).

-or-

The assigned value is greater than 32,000.

Setting this property to a value of -1 does not throw an exception if the value has not yet been changed from its default. This is because the control uses a value of -1 as an internal default before the control handle has been created. This internal default value causes the wrapped control to return its own default value of 19.

The following code example illustrates a customized TreeView. By inheriting the TreeView class, this custom version has all the functionality of a typical TreeView. Changing various property values in the constructor provides a unique appearance. Because the ShowPlusMinus property is set to false, the customized control also overrides the OnAfterSelect method so that nodes can be expanded and collapsed when they are clicked.

A control that is customized in this way can be used throughout an organization, making it easy to provide a consistent interface without requiring the control properties to be specified in each individual project.

No code example is currently available or this language may not be supported.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft