Filtering tasks
Filtering hides tasks that do not match a condition while keeping the schedule
intact — useful for focusing on one owner, one state, or unfinished work in a
large project. Build conditions programmatically with AddAND/AddOR using the
same predefined property names as columns, or apply a text expression with
Parse. Conditions apply immediately; there is no separate "apply" call.
procedure TForm1.FilterTasks;
begin
{ Keep matching tasks together with their parent chain. }
TMSFNCGanttChart1.Filter.FilterHierarchyMode := gfhParent;
{ Programmatic conditions are combined and applied immediately. }
TMSFNCGanttChart1.Filter.Clear;
TMSFNCGanttChart1.Filter.AddAND('taskname', feoStartsWith, 'D');
TMSFNCGanttChart1.Filter.AddAND('progress', feoSmallerThan, 50);
{ Or apply the same filter from a text expression. }
TMSFNCGanttChart1.Filter.FormatType := fftDelphiDataSet;
TMSFNCGanttChart1.Filter.Parse('[taskname] LIKE ''D%'' AND [progress] < 50');
{ Inspect and selectively remove conditions. }
if TMSFNCGanttChart1.Filter.HasFilter('progress') then
TMSFNCGanttChart1.Filter.RemovePropertyFilter('progress');
{ Remove every condition and show all tasks again. }
TMSFNCGanttChart1.Filter.Clear;
end;
void __fastcall TForm1::FilterTasks()
{
// Keep matching tasks together with their parent chain.
TMSFNCGanttChart1->Filter->FilterHierarchyMode = gfhParent;
// Programmatic conditions are combined and applied immediately.
TMSFNCGanttChart1->Filter->Clear();
TMSFNCGanttChart1->Filter->AddAND("taskname", feoStartsWith, TValue::From<System::UnicodeString>("D"));
TMSFNCGanttChart1->Filter->AddAND("progress", feoSmallerThan, TValue::From<int>(50));
// Or apply the same filter from a text expression.
TMSFNCGanttChart1->Filter->FormatType = fftDelphiDataSet;
TMSFNCGanttChart1->Filter->Parse("[taskname] LIKE 'D%' AND [progress] < 50");
// Inspect and selectively remove conditions.
if (TMSFNCGanttChart1->Filter->HasFilter("progress"))
TMSFNCGanttChart1->Filter->RemovePropertyFilter("progress");
// Remove every condition and show all tasks again.
TMSFNCGanttChart1->Filter->Clear();
}
Building conditions
AddAND and AddOR take a property name, an operator, a value, and optional
AInverted/ACaseSensitive flags. Operators come from the filter-builder set —
feoEqual, feoContains, feoStartsWith, feoEndsWith, feoSmallerThan,
feoLargerThan, and their relatives — so text and numeric properties each have a
natural comparison. Use the same predefined identifiers as columns
(taskname, progress, startdate, …) for the property name.
Text expressions
Parse applies a whole filter from a string, which is convenient when an
expression is stored or entered by a user. FormatType selects the syntax:
fftDelphiDataSet—[taskname] LIKE 'D%' AND [progress] < 50fftUniversalFilterExpressions—[taskname] = "D*" & [progress] < 50
FilterText and ParseFormat are exposed for reading back or persisting the
active expression.
Hierarchy modes
FilterHierarchyMode decides what context surrounds a matching task:
| Mode | Shows |
|---|---|
gfhParent |
Matches plus their full parent chain (default). |
gfhChildren |
Matches plus all of their subtasks. |
gfhBoth |
Both ancestors and descendants of a match. |
gfhStrict |
Only the matching tasks themselves. |
Clearing and inspecting conditions
Clear removes every condition and shows all tasks again; ClearFilter empties
the expressions while keeping the filter structure for reuse. HasFilter reports
whether a property is currently filtered, and RemovePropertyFilter drops just
the conditions for one property.
Putting it together
Build conditions, scope them to the parent hierarchy, and inspect/remove a condition — in one routine:
procedure TForm1.FilterAndInspect;
begin
{ Hierarchy mode: keep matching tasks together with their parents. }
TMSFNCGanttChart1.Filter.FilterHierarchyMode := gfhParent;
{ Building conditions programmatically. }
TMSFNCGanttChart1.Filter.Clear;
TMSFNCGanttChart1.Filter.AddAND('taskname', feoStartsWith, 'B');
TMSFNCGanttChart1.Filter.AddAND('progress', feoSmallerThan, 100);
{ Clearing and inspecting: drop one condition if it is present. }
if TMSFNCGanttChart1.Filter.HasFilter('taskname') then
TMSFNCGanttChart1.Filter.RemovePropertyFilter('taskname');
end;
void __fastcall TForm1::FilterAndInspect()
{
// Hierarchy mode: keep matching tasks together with their parents.
TMSFNCGanttChart1->Filter->FilterHierarchyMode = gfhParent;
// Building conditions programmatically.
TMSFNCGanttChart1->Filter->Clear();
TMSFNCGanttChart1->Filter->AddAND("taskname", feoStartsWith, TValue::From<System::UnicodeString>("B"));
TMSFNCGanttChart1->Filter->AddAND("progress", feoSmallerThan, TValue::From<int>(100));
// Clearing and inspecting: drop one condition if it is present.
if (TMSFNCGanttChart1->Filter->HasFilter("taskname"))
TMSFNCGanttChart1->Filter->RemovePropertyFilter("taskname");
}
See also
- Task list columns and sorting — the property names filters use.
- Expand and collapse — control task tree visibility.
TTMSFNCGanttChartAPI