alexa
menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download

    Show / Hide Table of Contents

    Class TreeGridSearchController

    Represents the Search operation which is performed in the TreeGrid.

    Inheritance
    System.Object
    TreeGridSearchController
    Implements
    System.IDisposable
    Namespace: Syncfusion.UI.Xaml.TreeGrid
    Assembly: Syncfusion.SfGrid.WPF.dll
    Syntax
    public class TreeGridSearchController : DependencyObject, IDisposable
    Remarks

    TreeGridSearchController provides methods to search, navigate, and highlight matching cells in an SfTreeGrid. It supports case-sensitive searching, filtering, and customizable search behavior through methods.

    Constructors

    TreeGridSearchController(SfTreeGrid)

    Initializes a new instance of the TreeGridSearchController class.

    Declaration
    public TreeGridSearchController(SfTreeGrid treeGrid)
    Parameters
    Type Name Description
    SfTreeGrid treeGrid

    The SfTreeGrid instance to associate with this search Controller.

    Fields

    AllowCaseSensitiveSearchProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty AllowCaseSensitiveSearchProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    AllowFilteringProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty AllowFilteringProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    CurrentMatchedCellBackgroundProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty CurrentMatchedCellBackgroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    CurrentMatchedCellForegroundProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty CurrentMatchedCellForegroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    MatchedCellBackgroundProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty MatchedCellBackgroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    MatchedCellForegroundProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty MatchedCellForegroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    Provider

    Gets the provider used to access cell values and formatted data.

    Declaration
    protected IPropertyAccessProvider Provider
    Field Value
    Type
    IPropertyAccessProvider

    SearchModeProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty SearchModeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    SearchScopeProperty

    Identifies the dependency property.

    Declaration
    public static readonly DependencyProperty SearchScopeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    TreeGrid

    Gets the TreeGrid instance associated with this search controller.

    Declaration
    protected SfTreeGrid TreeGrid
    Field Value
    Type
    SfTreeGrid

    Properties

    AllowCaseSensitiveSearch

    Gets or sets a value that enables case-sensitive string comparison during search in SfTreeGrid.

    Declaration
    public bool AllowCaseSensitiveSearch { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if case-sensitive search is enabled; otherwise, false. The default value is false.

    AllowFiltering

    Gets or sets a value that indicates whether to enable filter based on search text.

    Declaration
    public bool AllowFiltering { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the TreeGrid is filtered when Search(String) is called; otherwise, false. The default value is false.

    CurrentMatchedCellBackground

    Gets or sets a brush that highlights the search text of cell during FindNext(String) and FindPrevious(String) method calls.

    Declaration
    public Brush CurrentMatchedCellBackground { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Brush

    The background brush applied to the currently navigated matching text. The default value is System.Windows.Media.Brushes.LightSalmon.

    CurrentMatchedCellForeground

    Gets or sets a brush that highlights the search text foreground of a cell during FindNext(String) and FindPrevious(String) method calls.

    Declaration
    public Brush CurrentMatchedCellForeground { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Brush

    The foreground brush applied to the currently navigated matching text. The default value is System.Windows.Media.Brushes.Black.

    CurrentMatchedCellIndex

    Gets the RowColumnIndex of the cell that matches the search text when FindNext(String) and FindPrevious(String) methods are called.

    Declaration
    public RowColumnIndex CurrentMatchedCellIndex { get; set; }
    Property Value
    Type Description
    RowColumnIndex

    A RowColumnIndex indicating the row and column indices of the currently navigated matching cell, or (-1, -1) if no match has been navigated.

    MatchedCellBackground

    Gets or sets a brush that highlights the search text in SfTreeGrid.

    Declaration
    public Brush MatchedCellBackground { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Brush

    The background brush applied to matching text in cells. The default value is System.Windows.Media.Brushes.Yellow.

    MatchedCellForeground

    Gets or sets a brush to highlight search text foreground.

    Declaration
    public Brush MatchedCellForeground { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Brush

    The foreground brush applied to matching text in cells. The default value is System.Windows.Media.Brushes.Black.

    SearchMode

    Gets or sets the value that denotes how to compare cell values with search text.

    Declaration
    public SearchMode SearchMode { get; set; }
    Property Value
    Type Description
    SearchMode

    One of the SearchMode enumeration values. The default value is Contains.

    SearchScope

    Gets or sets the value that restricts the search to root nodes, child nodes, or both.

    Declaration
    public SearchScope SearchScope { get; set; }
    Property Value
    Type Description
    SearchScope

    One of the SearchScope enumeration values. The default value is Both.

    Methods

    Clear()

    Clears the text highlighting in the searched TextBlock of SfTreeGrid.

    Declaration
    public virtual void Clear()
    Remarks

    Clear() removes all cell highlighting, resets the current navigation index, and removes any active search filter. Only clears highlighting from rows that match the current SearchScope setting.

    Dispose()

    Releases the allocated resources used by the TreeGridSearchController class.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Releases the allocated resources used by the TreeGridSearchController class.

    Declaration
    protected virtual void Dispose(bool isDisposing)
    Parameters
    Type Name Description
    System.Boolean isDisposing

    Indicates whether the call is from Dispose method or from a finalizer.

    FindNext(String)

    Finds and highlights the next cell that matches the search text, and updates CurrentRowColumnIndex.

    Declaration
    public virtual bool FindNext(string text)
    Parameters
    Type Name Description
    System.String text

    The text to search for in the TreeGrid cells.

    Returns
    Type Description
    System.Boolean

    true if a matching cell is found and navigated to; otherwise, false.

    Remarks

    FindNext(String) advances through matching cells in the TreeGrid, applying to the navigated cell. Navigation respects the SearchScope filter to include only root, child, or both node types.

    FindPrevious(String)

    Finds and highlights the previous cell that matches the search text, and updates CurrentRowColumnIndex.

    Declaration
    public virtual bool FindPrevious(string text)
    Parameters
    Type Name Description
    System.String text

    The text to search for in the TreeGrid cells.

    Returns
    Type Description
    System.Boolean

    true if a matching cell is found and navigated to; otherwise, false.

    Remarks

    FindPrevious(String) moves backward through matching cells in the TreeGrid, applying CurrentMatchedCellBackground to the navigated cell. Navigation respects the SearchScope filter to include only root, child, or both node types.

    GetRecords()

    Searches and returns the collection of TreeGridSearchRowInfo.

    Declaration
    public List<TreeGridSearchRowInfo> GetRecords()
    Returns
    Type Description
    System.Collections.Generic.List<TreeGridSearchRowInfo>

    A System.Collections.Generic.List<T> of TreeGridSearchRowInfo containing matching records, or null if no search text is set.

    Remarks

    GetRecords() scans all records in the TreeGrid and returns information about which records match the current search text. Returns null if no search text is set. Only includes records that match the current SearchScope setting (root-nodes, child-nodes, or both).

    Search(String)

    Initiates a search operation in the TreeGrid based on the passed text.

    Declaration
    public virtual void Search(string text)
    Parameters
    Type Name Description
    System.String text

    The text to search for in the TreeGrid cells.

    Remarks

    Search(String) scans all visible rows in the TreeGrid and applies highlighting to cells that match the search text. If AllowFiltering is true, non-matching rows will be hidden. If the search text is null or empty, is called instead. Respects the SearchScope setting to highlight only applicable node types.

    SearchCell(TreeDataColumnBase, Object, Boolean)

    Searches for the SearchText in the TextBlocks of the specified cell and highlights matching text.

    Declaration
    protected virtual bool SearchCell(TreeDataColumnBase column, object record, bool applySearchHighlightBrush)
    Parameters
    Type Name Description
    TreeDataColumnBase column

    The TreeDataColumnBase containing the cell.

    System.Object record

    The data object associated with the cell.

    System.Boolean applySearchHighlightBrush

    true to apply CurrentMatchedCellBackground; otherwise, apply MatchedCellBackground.

    Returns
    Type Description
    System.Boolean

    true if the cell matches the search text; otherwise, false.

    Remarks

    Override this method to customize which cells can be searched or to restrict searching to specific column types.

    SearchRow(TreeDataRowBase)

    Searches the cells in the row to match with the SearchText.

    Declaration
    protected virtual void SearchRow(TreeDataRowBase row)
    Parameters
    Type Name Description
    TreeDataRowBase row

    The TreeDataRowBase to search.

    Remarks

    This method iterates through all visible columns in the row and calls SearchCell(TreeDataColumnBase, Object, Boolean) for each column.

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved