Sign in Join
Wiki copytemporary

TDBGrid/fr: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TDBGrid/fr

OldNewLine
1+**TDBGrid** ![](/wiki-images/3/37/Tdbgrid.png) est un composant qui affiche les données d'un [[TDataSet/fr|TDataSet]] sous forme tabulaire. Il est disponible depuis l'[[Data Controls tab/fr|onglet Data Controls]] de la [[Component Palette/fr|palette de composants]].
2+
3+``` pascal
4+ // configure connection with database
5+ SQLConnector1.ConnectorType := 'MySQL 5.1';
6+ SQLConnector1.HostName := 'MyServer';
7+ SQLConnector1.DatabaseName := 'MyDBName';
8+ SQLConnector1.UserName := 'MyName';
9+ SQLConnector1.Password := 'MyPass';
10+ // connect SQLConnector, SQLTransaction, DataSource, SQLQuery and DBGrid
11+ SQLTransaction1.Database := SQLConnector1;
12+ SQLQuery1.Transaction := SQLTransaction1;
13+ DataSource1.DataSet := SQLQuery1;
14+ DBGrid1.DataSource := DataSource1;
15+ // setup query to get (at least) two fields from MyTable
16+ SQLQuery1.SQL := 'SELECT * FROM MyTable';
17+ // setup grid with result from query
18+ DBGrid1.Columns[0].Title.Caption := 'Name';
19+ DBGrid1.Columns[0].FieldName := 'fieldDescription';
20+ DBGrid1.Columns[1].Title.Caption := 'Description';
21+ DBGrid1.Columns[1].FieldName := 'fieldName';
22+ // Open result and show in grid
23+ SQLQuery1.Open();
24+```
25+
26+# Voir aussi
27+
28+- [[doc:lcl/dbgrids/tdbgrid.html|Doc. TDBGrid]]
29+- [[TStringGrid/fr|TStringGrid]]
30+- [[Grids Reference Page/fr|Grids Reference Page]]
31+- [[TDataSource/fr|TDataSource]]
32+
33+---
34+*From the Free Pascal wiki, page "TDBGrid/fr", as it stood on 2020-02-29 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history