windowsforms-devexpress-dot-xtratreelist-dot-treelist-e12d0d79.md
Returns the list of checked nodes.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
public List<TreeListNode> GetAllCheckedNodes()
Public Function GetAllCheckedNodes As List(Of TreeListNode)
| Type | Description |
|---|---|
| List<TreeListNode> |
The list of checked nodes.
|
A node is checked if its TreeListNode.Checked property is true. The list returned by the GetAllCheckedNodes method does not include nodes with the indeterminate check state.
The following code shows how to retrieve checked nodes using the TreeList.GetAllCheckedNodes method, and modify their values.
List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {
decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;
node["BUDGET"] = budget;
}
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 example shows how to use a node iterator to retrieve unchecked TreeList nodes.
using DevExpress.XtraTreeList.Nodes.Operations;
GetUncheckedNodesOperation op = new GetUncheckedNodesOperation();
treeList1.NodesIterator.DoOperation(op);
//Get the number of unchecked nodes:
int count = op.TargetNodes.Count;
//The operation class that collects unchecked nodes
class GetUncheckedNodesOperation : TreeListOperation {
public List<TreeListNode> TargetNodes = new List<TreeListNode>();
public GetUncheckedNodesOperation() : base() { }
public override void Execute(TreeListNode node) {
if (node.CheckState == CheckState.Unchecked)
TargetNodes.Add(node);
}
}
Imports DevExpress.XtraTreeList.Nodes.Operations
Imports DevExpress.XtraTreeList.Nodes
Dim op As GetUncheckedNodesOperation = New GetUncheckedNodesOperation()
treeList1.NodesIterator.DoOperation(op)
'Get the number of unchecked nodes:
Dim count As Integer = op.TargetNodes.Count
'The operation class that collects unchecked nodes
Friend Class GetUncheckedNodesOperation
Inherits TreeListOperation
Public TargetNodes As List(Of TreeListNode) = New List(Of TreeListNode)()
Public Sub New()
MyBase.New()
End Sub
Public Overrides Sub Execute(ByVal node As TreeListNode)
If node.CheckState = CheckState.Unchecked Then
TargetNodes.Add(node)
End If
End Sub
End Class
See Node Checking - Checkboxes and Radio Buttons to learn more.
The following code shows how to retrieve checked nodes using the TreeList.GetAllCheckedNodes method, and modify their values.
List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {
decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;
node["BUDGET"] = budget;
}
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
See Also