TreeNode.StateImageIndex TreeNode.StateImageIndex TreeNode.StateImageIndex TreeNode.StateImageIndex Property


取得或設定影像的索引,用於在父代 TreeNodeTreeView 屬性設為 false 時,指示 CheckBoxes 的狀態。Gets or sets the index of the image that is used to indicate the state of the TreeNode when the parent TreeView has its CheckBoxes property set to false.

 property int StateImageIndex { int get(); void set(int value); };
public int StateImageIndex { get; set; }
member this.StateImageIndex : int with get, set
Public Property StateImageIndex As Integer


用來表示 TreeNode 狀態的影像索引。The index of the image that is used to indicate the state of the TreeNode.


指定的索引小於 -1 或大於 14。The specified index is less than -1 or greater than 14.


這個屬性所傳回的影像索引包含在父StateImageList TreeView控制項的屬性中。The image index that is returned by this property is contained in the StateImageList property of the parent TreeView control.

如果父系TreeView已啟用核取方塊StateImageIndex ,則會忽略,而節點會顯示父代TreeView中的StateImageList第一個或第二個影像,分別表示未核取或已檢查的狀態。If the parent TreeView has check boxes enabled, the StateImageIndex is ignored and the node will display the first or second image in the StateImageList set on the parent TreeView to indicate an unchecked or checked state, respectively. 切換屬性並不會影響的值StateImageIndexCheckedToggling the Checked property does not affect the value of the StateImageIndex.

StateImageIndex設定時,會傳回-1。The StateImageIndex returns -1 when not set. StateImageKeyStateImageIndex屬性是互斥的,也就是說,如果已設定,則會忽略另一個。The StateImageKey and StateImageIndex properties are mutually exclusive, meaning if one is set, the other is ignored. 如果您設定了StateImageKey屬性StateImageIndex ,屬性會自動設為-1。If you set the StateImageKey property, the StateImageIndex property is automatically set to -1. 或者,如果您設定StateImageIndexStateImageKey會自動設為空字串("")。Alternatively, if you set StateImageIndex, StateImageKey is automatically set to an empty string ("").