Back to Devexpress

How to: Dynamically Show and Hide Specific Nodes

windowsforms-2877-controls-and-libraries-tree-list-examples-how-to-dynamically-show-and-hide-specific-nodes.md

latest1.0 KB
Original Source

How to: Dynamically Show and Hide Specific Nodes

  • Nov 13, 2018

The example below ensures that Tree List records with the 15% discount are always visible, regardless of the currently applied filtering condition.

csharp
private void TreeList1_CustomRowFilter(object sender, CustomRowFilterEventArgs e) {
    TreeList treeList = sender as TreeList;
    string discount = treeList.GetRowCellDisplayText(e.Node, treeList.Columns["Discount"]);
    if (discount == "15%") {
        e.Visible = true;
        e.Handled = true;
    }
}
vb
Private Sub TreeList1_CustomRowFilter(ByVal sender As Object, ByVal e As CustomRowFilterEventArgs)
    Dim treeList As TreeList = TryCast(sender, TreeList)
    Dim discount As String = treeList.GetRowCellDisplayText(e.Node, treeList.Columns("Discount"))
    If discount = "15%" Then
        e.Visible = True
        e.Handled = True
    End If
End Sub