/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/gridfil0.pas
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/gridfil0.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 2987 byte(s)
Added tpsystools component
1 (* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is TurboPower SysTools
15 *
16 * The Initial Developer of the Original Code is
17 * TurboPower Software
18 *
19 * Portions created by the Initial Developer are Copyright (C) 1996-2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * ***** END LICENSE BLOCK ***** *)
25
26 unit gridfil0;
27
28 interface
29
30 uses
31 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
32 Grids, StdCtrls, ExtCtrls,
33
34 StTxtDat;
35
36 type
37 TForm1 = class(TForm)
38 Panel1: TPanel;
39 Button1: TButton;
40 StringGrid1: TStringGrid;
41 Button2: TButton;
42 OpenDialog1: TOpenDialog;
43 OpenDialog2: TOpenDialog;
44 procedure Button1Click(Sender: TObject);
45 procedure Button2Click(Sender: TObject);
46 procedure FormDestroy(Sender: TObject);
47 private
48 procedure ClearGrid(ClearCaptions: Boolean);
49 procedure FillCaptions;
50 procedure FillCells;
51 { Private declarations }
52 public
53 Schema : TStTextDataSchema;
54 DataSet : TStTextDataRecordSet;
55 { Public declarations }
56 end;
57
58 var
59 Form1: TForm1;
60
61 implementation
62
63 {$R *.DFM}
64
65 procedure TForm1.ClearGrid(ClearCaptions : Boolean);
66 var
67 i : Integer;
68 begin
69 if ClearCaptions then
70 StringGrid1.Rows[0].Clear;
71 for i := 1 to Pred(StringGrid1.RowCount) do
72 StringGrid1.Rows[i].Clear;
73 end;
74
75 procedure TForm1.FillCaptions;
76 begin
77 StringGrid1.ColCount := Schema.Captions.Count;
78 StringGrid1.Rows[0].Assign(Schema.Captions);
79 end;
80
81 procedure TForm1.FillCells;
82 var
83 i : Integer;
84 begin
85 StringGrid1.RowCount := DataSet.Count + 1;
86 i := 1;
87 DataSet.First;
88
89 while not DataSet.EOF do begin
90 StringGrid1.Rows[i].Assign(DataSet.CurrentRecord.Values);
91 DataSet.Next;
92 Inc(i);
93 end;
94
95 end;
96
97 procedure TForm1.Button1Click(Sender: TObject);
98 begin
99 if OpenDialog1.Execute then begin
100 ClearGrid(True);
101 Schema.Free;
102 Schema := TStTextDataSchema.Create;
103 Schema.LoadFromFile(OpenDialog1.FileName);
104 FillCaptions;
105 end;
106 end;
107
108 procedure TForm1.Button2Click(Sender: TObject);
109 begin
110 if OpenDialog2.Execute then begin
111 ClearGrid(False);
112 DataSet.Free;
113 DataSet := TStTextDataRecordSet.Create;
114 DataSet.Schema := Schema;
115 DataSet.LoadFromFile(OpenDialog2.FileName);
116 FillCells;
117 end;
118 end;
119
120 procedure TForm1.FormDestroy(Sender: TObject);
121 begin
122 Schema.Free;
123 DataSet.Free;
124 end;
125
126 end.

  ViewVC Help
Powered by ViewVC 1.1.20