Skip to main content

TcxTreeListDataFindCriteria.GetTextStartPositionByNode(TcxTreeListNode,Integer,string) Method

Returns a highlighted text match and its start position in a data cell within the specified node.

Declaration

function GetTextStartPositionByNode(ANode: TcxTreeListNode; AItemIndex: Integer; out AHighlightedText: string): Integer; virtual;

Parameters

Name Type
ANode TcxTreeListNode
AItemIndex Integer
AHighlightedText string

Returns

Type
Integer

Remarks

Call this function instead of the inherited GetTextStartPositionByRowIndex function to retrieve a highlighted text match from a visible node with a search result. Use the ANode and AItemIndex parameters to pass the target node and its data cell’s index. The function returns -1 if the specified node does not meet the active filter or search criteria, or the specified data cell’s value does not include text that matches an active criterion. Otherwise – the GetTextStartPositionByNode function returns an index of the character that starts a found text match. In this case, you can use the AHighlightedText parameter to retrieve the text match.

The following code example appends the first highlighted text match found in the “Job Title” column:

var
  ANode: TcxTreeListNode;
  AHighlightedText: string;
  AColumnIndex: Integer;
  I: Integer;
begin
  AColumnIndex := -1;
  AHighlightedText := '';
  for I := 0 to TreeList.ColumnCount - 1 do
    begin
      if TreeList.Columns[I].Caption.Text = 'Job Title' then
        begin
          AColumnIndex := I;
          break;
        end;
    end;
  if((TreeList.DataController.FindCriteria.MatchCount > 0) and (AColumnIndex <> -1)) then
    begin
      ANode := TreeList.DataController.FindCriteria.MatchNodes[0];
      TreeList.DataController.FindCriteria.GetTextStartPositionByNode(ANode, AColumnIndex, AHighlightedText);
      Caption := Caption + AHighlightedText;
    end;
end;

Note

A single data cell can have no more than one text match highlight, while a single node can have multiple text match highlights in different data cells. You can set a tree list control’s FindPanel.HighlightSearchResults property to False to disable text match highlights.

See Also