Skip to content

Commit ae38cd1

Browse files
committed
delphi: Focus the example on DevExpress Reports localization
- Switch languages using TcxRadioButtons. TcxRadioButtons better represent application state than simple buttons. - Use the German localization language when application starts. Check the "German" radiobutton to reflect the default localization. - Group "Display Report" buttons into a labeled group, change captions. Move focus to "Display Report Designer" button when application starts. - Forbid to resize the application form. - Give the application a relevant title. - Remove the Data Grid table. In this example, data structure is not in the focus of demonstration. Data Grid table draws attention from the localization examples. - Rename several interface components and code members according to DevExpress style. - Comment significant actions in the code example.
1 parent fa8f1e9 commit ae38cd1

2 files changed

Lines changed: 90 additions & 150 deletions

File tree

Delphi/uMainForm.dfm

Lines changed: 60 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,82 @@
11
object MainForm: TMainForm
22
Left = 0
33
Top = 0
4-
Caption = 'MainForm'
5-
ClientHeight = 483
6-
ClientWidth = 606
4+
BorderIcons = [biSystemMenu, biMinimize, biHelp]
5+
BorderStyle = bsSingle
6+
Caption = 'DevExpress Reports Localization Example'
7+
ClientHeight = 111
8+
ClientWidth = 411
79
Color = clBtnFace
810
Font.Charset = DEFAULT_CHARSET
911
Font.Color = clWindowText
1012
Font.Height = -12
1113
Font.Name = 'Segoe UI'
1214
Font.Style = []
15+
OnCreate = FormCreate
1316
TextHeight = 15
14-
object btnShowDesigner: TcxButton
15-
Left = 24
16-
Top = 32
17-
Width = 145
18-
Height = 25
19-
Caption = 'Show Designer'
20-
TabOrder = 0
21-
OnClick = btnShowDesignerClick
22-
end
23-
object btnViewReport: TcxButton
24-
Left = 192
25-
Top = 32
26-
Width = 193
27-
Height = 25
28-
Caption = 'View Report'
17+
object btnGroupDisplayDialog: TcxGroupBox
18+
Left = 211
19+
Top = 17
20+
Caption = 'Display a Localized Report Dialog:'
2921
TabOrder = 1
30-
OnClick = btnViewReportClick
31-
end
32-
object cxGrid1: TcxGrid
33-
Left = 24
34-
Top = 176
35-
Width = 521
36-
Height = 265
37-
TabOrder = 2
38-
object gvCategories: TcxGridDBTableView
39-
DataController.DataSource = DataModule1.dsCategories
40-
DataController.KeyFieldNames = 'CategoryID'
41-
object gvCategoriesCategoryID: TcxGridDBColumn
42-
DataBinding.FieldName = 'CategoryID'
43-
end
44-
object gvCategoriesCategoryName: TcxGridDBColumn
45-
DataBinding.FieldName = 'CategoryName'
46-
end
47-
object gvCategoriesDescription: TcxGridDBColumn
48-
DataBinding.FieldName = 'Description'
49-
end
50-
end
51-
object gvProducts: TcxGridDBTableView
52-
DataController.DataSource = DataModule1.dsProducts
53-
DataController.DetailKeyFieldNames = 'CategoryID'
54-
DataController.KeyFieldNames = 'ProductID'
55-
DataController.MasterKeyFieldNames = 'CategoryID'
56-
object gvProductsProductID: TcxGridDBColumn
57-
DataBinding.FieldName = 'ProductID'
58-
end
59-
object gvProductsProductName: TcxGridDBColumn
60-
DataBinding.FieldName = 'ProductName'
61-
Width = 244
62-
end
63-
object gvProductsSupplierID: TcxGridDBColumn
64-
DataBinding.FieldName = 'SupplierID'
65-
end
66-
object gvProductsCategoryID: TcxGridDBColumn
67-
DataBinding.FieldName = 'CategoryID'
68-
end
69-
object gvProductsQuantityPerUnit: TcxGridDBColumn
70-
DataBinding.FieldName = 'QuantityPerUnit'
71-
Width = 124
72-
end
73-
object gvProductsUnitPrice: TcxGridDBColumn
74-
DataBinding.FieldName = 'UnitPrice'
75-
end
76-
object gvProductsUnitsInStock: TcxGridDBColumn
77-
DataBinding.FieldName = 'UnitsInStock'
78-
end
79-
object gvProductsUnitsOnOrder: TcxGridDBColumn
80-
DataBinding.FieldName = 'UnitsOnOrder'
81-
end
82-
object gvProductsReorderLevel: TcxGridDBColumn
83-
DataBinding.FieldName = 'ReorderLevel'
84-
end
85-
object gvProductsDiscontinued: TcxGridDBColumn
86-
DataBinding.FieldName = 'Discontinued'
87-
Width = 34
88-
end
89-
object gvProductsEAN13: TcxGridDBColumn
90-
DataBinding.FieldName = 'EAN13'
91-
Width = 76
92-
end
22+
Height = 86
23+
Width = 192
24+
object btnDisplayReport: TcxButton
25+
Left = 15
26+
Top = 52
27+
Width = 145
28+
Height = 25
29+
Caption = 'Report Viewer'
30+
TabOrder = 1
31+
OnClick = btnDisplayReportClick
9332
end
94-
object cxGrid1Level1: TcxGridLevel
95-
GridView = gvCategories
96-
object cxGrid1Level2: TcxGridLevel
97-
GridView = gvProducts
98-
end
33+
object btnDisplayDesigner: TcxButton
34+
Left = 15
35+
Top = 21
36+
Width = 145
37+
Height = 25
38+
Caption = 'Report Designer'
39+
TabOrder = 0
40+
OnClick = btnDisplayDesignerClick
9941
end
10042
end
101-
object btnSetLanguageUS: TcxButton
102-
Left = 72
103-
Top = 88
104-
Width = 121
105-
Height = 25
106-
Caption = 'English'
107-
TabOrder = 3
108-
OnClick = btnSetLanguageUSClick
109-
end
110-
object btnSetLanguageDE: TcxButton
111-
Left = 199
112-
Top = 88
113-
Width = 131
114-
Height = 25
115-
Caption = 'German'
116-
TabOrder = 4
117-
OnClick = btnSetLanguageDEClick
118-
end
119-
object lblSelectLanguage: TcxLabel
120-
Left = 56
121-
Top = 64
122-
Caption = 'Select Language'
123-
TabOrder = 5
43+
object rbtnGroupLocalization: TcxRadioGroup
44+
Left = 8
45+
Top = 17
46+
Caption = 'Localize Report Dialogs in:'
47+
Properties.Items = <>
48+
TabOrder = 0
49+
Height = 86
50+
Width = 185
51+
object rbtnSelectEnglishLocalization: TcxRadioButton
52+
Left = 16
53+
Top = 25
54+
Width = 113
55+
Height = 17
56+
Caption = 'English (en-US)'
57+
TabOrder = 0
58+
OnClick = rbtnSelectEnglishLocalizationClick
59+
end
60+
object rbtnSelectGermanLocalization: TcxRadioButton
61+
Left = 16
62+
Top = 56
63+
Width = 113
64+
Height = 17
65+
Caption = 'German (de-DE)'
66+
Checked = True
67+
TabOrder = 1
68+
TabStop = True
69+
OnClick = rbtnSelectGermanLocalizationClick
70+
end
12471
end
12572
object dxReport1: TdxReport
12673
Parameters = <>
127-
Left = 48
128-
Top = 128
74+
Left = 416
75+
Top = 32
12976
end
13077
object dxBackendDataConnectionManager1: TdxBackendDataConnectionManager
131-
Left = 112
132-
Top = 128
78+
Left = 472
79+
Top = 32
13380
object dxBackendDataConnectionManager1dxBackendDataSetJSONConnection1: TdxBackendDataSetJSONConnection
13481
DisplayName = 'DataSetConnection'
13582
object itmProducts: TdxBackendDataSetCollectionItem

Delphi/uMainForm.pas

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,26 @@ interface
1212
cxGridTableView, cxGridDBTableView, cxGrid, FireDAC.Comp.DataSet,
1313
FireDAC.Comp.Client, dxBackend.ConnectionString.JSON.DataSet,
1414
dxBackend.ConnectionString.JSON, Vcl.StdCtrls, dxmdaset, uData, cxContainer,
15-
cxLabel;
15+
cxLabel, cxRadioGroup, cxGroupBox;
1616

1717
type
1818
TMainForm = class(TForm)
1919
dxReport1: TdxReport;
2020
dxBackendDataConnectionManager1: TdxBackendDataConnectionManager;
21-
btnShowDesigner: TcxButton;
22-
btnViewReport: TcxButton;
21+
btnDisplayDesigner: TcxButton;
22+
btnDisplayReport: TcxButton;
2323
dxBackendDataConnectionManager1dxBackendDataSetJSONConnection1: TdxBackendDataSetJSONConnection;
2424
itmProducts: TdxBackendDataSetCollectionItem;
2525
itmCategories: TdxBackendDataSetCollectionItem;
26-
cxGrid1: TcxGrid;
27-
gvCategories: TcxGridDBTableView;
28-
gvCategoriesCategoryID: TcxGridDBColumn;
29-
gvCategoriesCategoryName: TcxGridDBColumn;
30-
gvCategoriesDescription: TcxGridDBColumn;
31-
gvProducts: TcxGridDBTableView;
32-
gvProductsProductID: TcxGridDBColumn;
33-
gvProductsProductName: TcxGridDBColumn;
34-
gvProductsSupplierID: TcxGridDBColumn;
35-
gvProductsCategoryID: TcxGridDBColumn;
36-
gvProductsQuantityPerUnit: TcxGridDBColumn;
37-
gvProductsUnitPrice: TcxGridDBColumn;
38-
gvProductsUnitsInStock: TcxGridDBColumn;
39-
gvProductsUnitsOnOrder: TcxGridDBColumn;
40-
gvProductsReorderLevel: TcxGridDBColumn;
41-
gvProductsDiscontinued: TcxGridDBColumn;
42-
gvProductsEAN13: TcxGridDBColumn;
43-
cxGrid1Level1: TcxGridLevel;
44-
cxGrid1Level2: TcxGridLevel;
45-
btnSetLanguageUS: TcxButton;
46-
btnSetLanguageDE: TcxButton;
47-
lblSelectLanguage: TcxLabel;
48-
procedure btnShowDesignerClick(Sender: TObject);
49-
procedure btnViewReportClick(Sender: TObject);
50-
procedure btnSetLanguageUSClick(Sender: TObject);
51-
procedure btnSetLanguageDEClick(Sender: TObject);
26+
rbtnGroupLocalization: TcxRadioGroup;
27+
rbtnSelectEnglishLocalization: TcxRadioButton;
28+
rbtnSelectGermanLocalization: TcxRadioButton;
29+
btnGroupDisplayDialog: TcxGroupBox;
30+
procedure FormCreate(Sender: TObject);
31+
procedure btnDisplayDesignerClick(Sender: TObject);
32+
procedure btnDisplayReportClick(Sender: TObject);
33+
procedure rbtnSelectEnglishLocalizationClick(Sender: TObject);
34+
procedure rbtnSelectGermanLocalizationClick(Sender: TObject);
5235
private
5336
{ Private declarations }
5437
public
@@ -62,24 +45,34 @@ implementation
6245

6346
{$R *.dfm}
6447

65-
procedure TMainForm.btnSetLanguageDEClick(Sender: TObject);
48+
procedure TMainForm.FormCreate(Sender: TObject);
6649
begin
67-
dxReport1.Language := 'de-DE'
50+
// Switch to German localization when the application starts
51+
dxReport1.Language := 'de-DE';
6852
end;
6953

70-
procedure TMainForm.btnSetLanguageUSClick(Sender: TObject);
54+
procedure TMainForm.btnDisplayDesignerClick(Sender: TObject);
7155
begin
72-
dxReport1.Language := 'en-US'
56+
// Display the DevExpress Report Designer dialog
57+
dxReport1.ShowDesigner;
7358
end;
7459

75-
procedure TMainForm.btnShowDesignerClick(Sender: TObject);
60+
procedure TMainForm.btnDisplayReportClick(Sender: TObject);
7661
begin
77-
dxReport1.ShowDesigner;
62+
// Display the DevExpress Report Viewer dialog
63+
dxReport1.ShowViewer;
7864
end;
7965

80-
procedure TMainForm.btnViewReportClick(Sender: TObject);
66+
procedure TMainForm.rbtnSelectEnglishLocalizationClick(Sender: TObject);
8167
begin
82-
dxReport1.ShowViewer;
68+
// Switch to English localization
69+
dxReport1.Language := 'en-US';
70+
end;
71+
72+
procedure TMainForm.rbtnSelectGermanLocalizationClick(Sender: TObject);
73+
begin
74+
// Switch to German localization
75+
dxReport1.Language := 'de-DE';
8376
end;
8477

8578
end.

0 commit comments

Comments
 (0)