TTMSFNCDataGrid.Options Property
General feature and behavior options for the grid.
API unit family: TMSFNCDataGrid
Declaring type: TTMSFNCDataGrid
Inherited from: TTMSFNCCustomDataGrid
Type: TTMSFNCDataGridOptions
Syntax
property Options: TTMSFNCDataGridOptions;
__property TTMSFNCDataGridOptions* Options = {read=GetOptions, write=SetOptions};
Usage examples
Excel-style AutoFill with custom lists and computed values
Enable the AutoFill drag handle, register custom lists (Q1..Q4, TODO/Done, ...), and override the value calculation when the built-in detection isn't enough.
procedure TForm1.FormCreate(Sender: TObject);
begin
// Show the AutoFill handle on the active selection
Grid.Options.Selection.Mode := gsmCellRange;
Grid.Options.Selection.AutoFill := True;
// Register custom lists that AutoFill recognises and cycles through
Grid.AutoFillCustomListSet('StatusList',
['TODO', 'In Progress', 'Review', 'Done']);
Grid.AutoFillCustomListSet('PriorityList',
['Low', 'Medium', 'High', 'Critical']);
Grid.AutoFillCustomListSet('QuarterList',
['Q1', 'Q2', 'Q3', 'Q4']);
// Hook the calculation event for cases the built-in detector cannot handle.
Grid.OnAutoFillCalculateValue := AutoFillCalculate;
end;
procedure TForm1.AutoFillCalculate(Sender: TObject;
SourceCells: TTMSFNCDataGridCellCoordRange;
SourceValues: TTMSFNCDataGridDataValues;
TargetCells: TTMSFNCDataGridCellCoordRange;
FillIndex: Integer;
Direction: TTMSFNCDataGridDataAutoFillDirection;
var NewValue: TTMSFNCDataGridCellValue;
var Handled: Boolean);
begin
// Example: continue a sequence of single lowercase letters (a, b -> c, d, ...)
if (Length(SourceValues) >= 2) then
begin
NewValue := Char(Ord('a') + FillIndex mod 26);
Handled := True;
end;
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// Show the AutoFill handle on the active selection
Grid->Options->Selection->Mode = gsmCellRange;
Grid->Options->Selection->AutoFill = true;
// Register custom lists that AutoFill recognises and cycles through
Grid->AutoFillCustomListSet("StatusList",
OPENARRAY(System::UnicodeString, ("TODO", "In Progress", "Review", "Done")));
Grid->AutoFillCustomListSet("PriorityList",
OPENARRAY(System::UnicodeString, ("Low", "Medium", "High", "Critical")));
Grid->AutoFillCustomListSet("QuarterList",
OPENARRAY(System::UnicodeString, ("Q1", "Q2", "Q3", "Q4")));
// Hook the calculation event for cases the built-in detector cannot handle.
Grid->OnAutoFillCalculateValue = AutoFillCalculate;
}
void __fastcall TForm1::AutoFillCalculate(TObject *Sender,
const TTMSFNCDataGridCellCoordRange &SourceCells,
TTMSFNCDataGridDataValues SourceValues,
const TTMSFNCDataGridCellCoordRange &TargetCells,
int FillIndex,
TTMSFNCDataGridDataAutoFillDirection Direction,
TTMSFNCDataGridCellValue &NewValue,
bool &Handled)
{
// Example: continue a sequence of single lowercase letters (a, b -> c, d, ...)
if (SourceValues.Length >= 2)
{
NewValue = TValue::From<System::UnicodeString>(System::UnicodeString((wchar_t)('a' + FillIndex % 26)));
Handled = true;
}
}
Combine reordering, file drops, and drag indicator styling
Enable internal row/column reordering, accept dropped files, and style the drag indicator consistently.
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid.Options.Mouse.ColumnDragging := True;
Grid.Options.Mouse.RowDragging := True;
Grid.AcceptDropFiles := True;
Grid.OnDropFiles := GridDropFiles;
Grid.DragAppearance.Fill.Color := $200080FF;
Grid.DragAppearance.Stroke.Color := $FF0080FF;
Grid.DragAppearance.Size := 3;
end;
procedure TForm1.GridDropFiles(Sender: TObject;
ADropFiles: TTMSFNCCustomControlDropFiles);
begin
if ADropFiles.Count > 0 then
Grid.LoadFromCSVData(ADropFiles[0]);
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Grid->Options->Mouse->ColumnDragging = true;
Grid->Options->Mouse->RowDragging = true;
Grid->AcceptDropFiles = true;
Grid->OnDropFiles = GridDropFiles;
Grid->DragAppearance->Fill->Color = (TTMSFNCGraphicsColor)0x200080FF;
Grid->DragAppearance->Stroke->Color = (TTMSFNCGraphicsColor)0xFF0080FF;
Grid->DragAppearance->Size = 3;
}
void __fastcall TForm1::GridDropFiles(TObject *Sender,
TTMSFNCCustomControlDropFiles *ADropFiles)
{
if (ADropFiles->Files->Count > 0)
Grid->LoadFromCSVData(ADropFiles->Files->Strings[0]);
}
Add an in-grid filter editor row
Configure a dedicated editor row above the data so users can filter every column live, with type-aware editors and multi-column AND.
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid.LoadFromCSVData('CARS.csv');
// Reserve row 1 of the grid for filter editors; row 0 stays as the header.
Grid.FixedRowCount := 2;
Grid.InsertRow(1);
// Switch on filtering with both header buttons AND in-row editors
Grid.Options.Filtering.Enabled := True;
Grid.Options.Filtering.Row := 1;
Grid.Options.Filtering.Controls := [gfcButton, gfcEditor];
Grid.Options.Filtering.MultiColumn := True;
end;
procedure TForm1.PriceComboChange(Sender: TObject);
var
fltr: TTMSFNCDataGridDataFilterData;
begin
Grid.RemoveFilter;
if PriceEdit.Text <> '' then
begin
fltr := Grid.Filter.ColumnFilter[7];
fltr.&Type := TTMSFNCDataGridDataFilterNumberType(PriceCombo.ItemIndex);
fltr.Condition := PriceEdit.Text;
end;
Grid.ApplyFilter;
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Grid->LoadFromCSVData("CARS.csv");
// Reserve row 1 of the grid for filter editors; row 0 stays as the header.
Grid->FixedRowCount = 2;
Grid->InsertRow(1);
// Switch on filtering with both header buttons AND in-row editors
Grid->Options->Filtering->Enabled = true;
Grid->Options->Filtering->Row = 1;
Grid->Options->Filtering->Controls = TTMSFNCDataGridDataFilterControls() << gfcButton << gfcEditor;
Grid->Options->Filtering->MultiColumn = true;
}
void __fastcall TForm1::PriceComboChange(TObject *Sender)
{
Grid->RemoveFilter();
if (PriceEdit->Text != "")
{
TTMSFNCDataGridDataFilterData *fltr = Grid->Filter->ColumnFilter[7];
fltr->Type = (TTMSFNCDataGridDataFilterNumberType)PriceCombo->ItemIndex;
fltr->Condition = PriceEdit->Text;
}
Grid->ApplyFilter();
}
Combine filter row editors with grouped rows
Reserve a filter row, enable multi-column filtering, and hide grouped buckets that no longer contain visible rows.
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid.LoadFromCSVData('CARS.csv');
Grid.FixedRowCount := 2;
Grid.InsertRow(1);
Grid.Options.Filtering.Enabled := True;
Grid.Options.Filtering.Row := 1;
Grid.Options.Filtering.Controls := [gfcButton, gfcEditor];
Grid.Options.Filtering.MultiColumn := True;
Grid.Options.Filtering.HideEmptyGroups := True;
Grid.Group(BrandColumn);
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Grid->LoadFromCSVData("CARS.csv");
Grid->FixedRowCount = 2;
Grid->InsertRow(1);
Grid->Options->Filtering->Enabled = true;
Grid->Options->Filtering->Row = 1;
Grid->Options->Filtering->Controls = TTMSFNCDataGridDataFilterControls() << gfcButton << gfcEditor;
Grid->Options->Filtering->MultiColumn = true;
Grid->Options->Filtering->HideEmptyGroups = true;
Grid->Group(BrandColumn);
}
Configure keyboard navigation and mouse interaction
Switch on direct-edit keys, choose Tab/Enter behaviour, and pick a selection mode (single cell, row, range, or disjunct).
procedure TForm1.FormCreate(Sender: TObject);
begin
// Direct edit: typing a character starts editing immediately
Grid.Options.Keyboard.TabKeyDirectEdit := True;
Grid.Options.Keyboard.ArrowKeyDirectEdit := True;
Grid.Options.Keyboard.EnterKeyDirectEdit := True;
// What does Enter do? Move down (default), move right, or stay put.
Grid.Options.Keyboard.EnterKeyMove := gkmMoveDown;
// Selection style
Grid.Options.Selection.Mode := gsmCellRange; // contiguous range
// Other modes: gsmSingleCell, gsmRow, gsmDisjunctRow, gsmDisjunctCellRange
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// Direct edit: typing a character starts editing immediately
Grid->Options->Keyboard->TabKeyDirectEdit = true;
Grid->Options->Keyboard->ArrowKeyDirectEdit = true;
Grid->Options->Keyboard->EnterKeyDirectEdit = true;
// What does Enter do? Move to the next row (default), the next column, or stay put.
Grid->Options->Keyboard->EnterKeyHandling = gekhNextRow;
// Selection style
Grid->Options->Selection->Mode = gsmCellRange; // contiguous range
// Other modes: gsmSingleCell, gsmRow, gsmDisjunctRow, gsmDisjunctCellRange
}