Back to Devexpress

TreeListNode.CheckState Property

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-4a581ea6.md

latest5.6 KB
Original Source

TreeListNode.CheckState Property

Gets or sets the node’s check state.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
[DefaultValue(CheckState.Unchecked)]
[DXCategory("Behavior")]
public virtual CheckState CheckState { get; set; }
vb
<DefaultValue(CheckState.Unchecked)>
<DXCategory("Behavior")>
Public Overridable Property CheckState As CheckState

Property Value

TypeDefaultDescription
CheckStateUnchecked

A CheckState enumeration value that specifies the node’s check state.

|

Remarks

If the TreeListOptionsBehavior.AllowIndeterminateCheckState option is disabled, a node can have two states: checked and unchecked. In this mode, to get/set check states, use the TreeListNode.Checked property.

If the TreeListOptionsBehavior.AllowIndeterminateCheckState option is enabled, three check states are supported: checked, unchecked and indeterminate. In this instance, use the CheckState property to get/set a node’s state.

See Node Checking - Checkboxes and Radio Buttons to learn more.

Example

The following code shows how to retrieve checked nodes using the TreeList.GetAllCheckedNodes method, and modify their values.

csharp
List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {
    decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;
    node["BUDGET"] = budget;
}
vb
Dim list As List(Of TreeListNode) = treeList1.GetAllCheckedNodes()
For Each node As TreeListNode In list
    Dim budget As Decimal = Convert.ToDecimal(node("BUDGET")) * 1.1D
    node("BUDGET") = budget
Next

The following code snippets (auto-collected from DevExpress Examples) contain references to the CheckState property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.cs#L148

csharp
object id = item[0];
    tree.FindNodeByFieldValue(dashboardItem.Metadata.ID.UniqueId, id).CheckState = CheckState.Checked;
}

winforms-treelist-custom-check-nodes-behavior/CS/Example/TreeListCheckHelper.cs#L22

csharp
foreach(TreeListNode childNode in node.Nodes)
    if(childNode.CheckState == CheckState.Checked)
        return true;

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.vb#L155

vb
Dim id As Object = item(0)
    tree.FindNodeByFieldValue(dashboardItem.Metadata.ID.UniqueId, id).CheckState = CheckState.Checked
Next item

winforms-treelist-custom-check-nodes-behavior/VB/Example/TreeListCheckHelper.vb#L19

vb
For Each childNode As TreeListNode In node.Nodes
    If childNode.CheckState = CheckState.Checked Then
        Return True

See Also

Checked

Node Checking - Checkboxes and Radio Buttons

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace