Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeView.SetNodesChecked(Func<ITreeViewNodeInfo, Boolean>, Boolean) Method

Checks or unchecks the specified nodes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void SetNodesChecked(
    Func<ITreeViewNodeInfo, bool> predicate,
    bool check
)

#Parameters

Name Type Description
predicate Func<ITreeViewNodeInfo, Boolean>

A method delegate that specifies particular nodes.

check Boolean

true to check nodes; false to uncheck nodes.

#Remarks

Use the SetNodesChecked method to check or uncheck the specified nodes in code.

The following code snippet expands the specified node and checks all its child nodes:

@using TreeView.Data

<DxTreeView @ref="MyTreeView"
            Data=@DataFlatSource.DataFlat
            CheckMode="TreeViewCheckMode.Multiple">
    <DataMappings>
        <DxTreeViewDataMapping Text="Product"
                               Key="Id"
                               ParentKey="ParentId" />
    </DataMappings>
</DxTreeView>

@code {
    DxTreeView MyTreeView;

    protected override void OnAfterRender(bool firstRender) {
        base.OnAfterRender(firstRender);
        if(firstRender) {
            MyTreeView.SetNodeExpanded(n => n.Text == "Clothing", true);
            MyTreeView.SetNodesChecked(n => n.Parent?.Text == "Clothing", true);
        }
    }
}
See Also