TAdvStringGrid
Example 78 : Incremental filtering & narrow down capabilities

with grid.Filter.Add do begin Condition := 'sometext'; Data := fcRow; end; grid.FilterActive := true;
Incrementally applying filters can be done by calling grid.ApplyFilter several times after each other. To remove the last filter or to remove all filters call grid.RemoveLastFilter or grid.RemoveAllFilters respectively. In the code snippet below, two filters are applied after each other and finally the last filter operation is removed, leaving the result of the first applied filter:
procedure TForm2.Button1Click(Sender: TObject); begin with advstringgrid1.Filter.Add do begin condition := '>50'; column := 1; end; advstringgrid1.ApplyFilter; with advstringgrid1.Filter.Add do begin condition := '<75'; column := 1; end; advstringgrid1.ApplyFilter; advstringgrid1.RemoveLastFilter; end;
A last new feature is the Narrow-Down capability. With this method, the grid can filter in incremental steps to find all rows with a specific word or all rows that have a specific word in one column. In the demo, the edit control's OnChange method event handler just calls grid.NarrowDown(searchvalue). This causes that the grid will always show all rows containing the word in the edit control as the user types the search specification in the edit control. The checkbox controls whether the search for a word in a row is done for the full row or restricted to one column only (column 1 in this case):
procedure TForm2.Edit1Change(Sender: TObject); begin if checkbox1.checked then advstringgrid1.NarrowDown(Edit1.Text, 1) else advstringgrid1.NarrowDown(Edit1.Text); end;
Delphi project & source files for downloading included in the main demos distribution for Delphi
×