Back to Devexpress

TreeListView.CheckAllNodes() Method

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-c6a28b50.md

latest3.3 KB
Original Source

TreeListView.CheckAllNodes() Method

Checks all nodes.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public void CheckAllNodes()
vb
Public Sub CheckAllNodes

Remarks

You can embed check boxes into nodes to allow an end user to check/uncheck individual nodes.

Embed Check Boxes into Nodes

  1. Set the TreeListView.ShowCheckboxes property to true to display check boxes embedded into nodes.

  2. Set values of check boxes. Do one of the following:

The code sample below shows how to display check boxes and bind them to the OnVacation field:

xaml
<dxg:GridControl Name="gridControl">
    <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="Name"/>
        <dxg:GridColumn FieldName="Department"/>
        <dxg:GridColumn FieldName="Position"/>
    </dxg:GridControl.Columns>
    <dxg:GridControl.View>
        <dxg:TreeListView KeyFieldName="ID" ParentFieldName="ParentID" AutoExpandAllNodes="True"
            CheckBoxFieldName="OnVacation" ShowCheckboxes="True" />
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
public class Employee {
    public int ID { get; set; }
    public int ParentID { get; set; }
    public string Name { get; set; }
    public string Position { get; set; }
    public string Department { get; set; }
    public bool OnVacation { get; set; }
}
vb
Public Class Employee
    Public Property ID As Integer
    Public Property ParentID As Integer
    Public Property Name As String
    Public Property Position As String
    Public Property Department As String
    Public Property OnVacation As Boolean
End Class

Check Nodes in Code

Use the following methods to check/uncheck nodes in code:

MethodDescription
TreeListView.CheckAllNodesChecks all nodes.
TreeListView.UncheckAllNodesUnchecks all nodes.
TreeListNode.IsCheckedChecks/unchecks the node.

When a node’s check state is changed, the TreeList View raises the TreeListView.NodeCheckStateChanged event. Use the TreeListNode.IsChecked property to identify whether a node is checked.

See Also

UncheckAllNodes()

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace