- Регистрация
- 9 Май 2015
- Сообщения
- 1,486
- Баллы
- 155
Intro
If you’re developing in Delphi and looking for a powerful, flexible, and highly customizable data grid solution, then is the perfect choice. In this blog, we'll demonstrate how to drag & drop files from the operating system and load data into the grid.
What is TMS FNC Data Grid?
To have a better understanding on what TMS FNC Data Grid is and has to offer, please read through first.
Enabling file drag & drop
To allow files from the operating system to be dropped into the grid, set
Grid.AcceptDropFiles := True;
When you drag a file, the OnDropFiles event is triggered. However, no further actions are performed automatically. If you want to load a specific file, you'll need to handle this manually. For this blog, we’ve created a simple sample CSV data file.
procedure TForm1.GridDropFiles(Sender: TObject;
ADropFiles: TTMSFNCCustomControlDropFiles);
var
f: string;
begin
if ADropFiles.Files.Count > 0 then
begin
f := ADropFiles.Files[0];
if ExtractFileExt(f) = '.csv' then
begin
Grid.Clear;
Grid.LoadFromCSVData(f);
end;
end;
end;
It’s possible to either block or accept the drag-and-drop action based on the file list. When performing a drag file operation, the OnDragOver event is triggered, and the source object will be of type TTMSFNCCustomControlDropFiles. Two convenience methods are available for this: IsSourceDropFiles & AsSourceDropFiles.
procedure TForm1.GridDragOver(Sender: TObject;
const Data: TDragObject; const Point: TPointF; var Operation: TDragOperation);
var
df: TTMSFNCCustomControlDropFiles;
I: Integer;
a: Boolean;
begin
if IsSourceDropFiles(Data.Source) then
begin
df := AsSourceDropFiles(Data.Source);
a := False;
for I := 0 to df.Files.Count - 1 do
begin
if ExtractFileExt(df.Files) = '.csv' then
begin
a := True;
Break;
end;
end;
if a then
Operation := TDragOperation.Link
else
Operation := TDragOperation.None
end;
end;
Conclusion
The TMS FNC Data Grid is a powerful and flexible component for Delphi developers, offering extensive features for displaying, managing, and interacting with data. Whether you're building a desktop, mobile or web application, this grid can handle a wide range of data scenarios while providing a sleek, modern user interface.
In this blog, we’ve demonstrated how you can drag & drop a file from the operating system to the grid, but its capabilities go far beyond what we’ve shown here. We encourage you to explore its features to fully unlock its potential in your applications.
If you’re developing in Delphi and looking for a powerful, flexible, and highly customizable data grid solution, then is the perfect choice. In this blog, we'll demonstrate how to drag & drop files from the operating system and load data into the grid.
What is TMS FNC Data Grid?
To have a better understanding on what TMS FNC Data Grid is and has to offer, please read through first.

Enabling file drag & drop
To allow files from the operating system to be dropped into the grid, set
Grid.AcceptDropFiles := True;
When you drag a file, the OnDropFiles event is triggered. However, no further actions are performed automatically. If you want to load a specific file, you'll need to handle this manually. For this blog, we’ve created a simple sample CSV data file.

procedure TForm1.GridDropFiles(Sender: TObject;
ADropFiles: TTMSFNCCustomControlDropFiles);
var
f: string;
begin
if ADropFiles.Files.Count > 0 then
begin
f := ADropFiles.Files[0];
if ExtractFileExt(f) = '.csv' then
begin
Grid.Clear;
Grid.LoadFromCSVData(f);
end;
end;
end;
It’s possible to either block or accept the drag-and-drop action based on the file list. When performing a drag file operation, the OnDragOver event is triggered, and the source object will be of type TTMSFNCCustomControlDropFiles. Two convenience methods are available for this: IsSourceDropFiles & AsSourceDropFiles.
procedure TForm1.GridDragOver(Sender: TObject;
const Data: TDragObject; const Point: TPointF; var Operation: TDragOperation);
var
df: TTMSFNCCustomControlDropFiles;
I: Integer;
a: Boolean;
begin
if IsSourceDropFiles(Data.Source) then
begin
df := AsSourceDropFiles(Data.Source);
a := False;
for I := 0 to df.Files.Count - 1 do
begin
if ExtractFileExt(df.Files) = '.csv' then
begin
a := True;
Break;
end;
end;
if a then
Operation := TDragOperation.Link
else
Operation := TDragOperation.None
end;
end;

Conclusion
The TMS FNC Data Grid is a powerful and flexible component for Delphi developers, offering extensive features for displaying, managing, and interacting with data. Whether you're building a desktop, mobile or web application, this grid can handle a wide range of data scenarios while providing a sleek, modern user interface.
In this blog, we’ve demonstrated how you can drag & drop a file from the operating system to the grid, but its capabilities go far beyond what we’ve shown here. We encourage you to explore its features to fully unlock its potential in your applications.