Project MULTI2
Project Structure
MULTI2.DPR
program Multi2;
uses
Forms,
MultiRec in 'MultiRec.pas' {Form1};
{$R *.RES}
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
MULTIREC.PAS
unit MultiRec;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, DBCtrls, DBTables, DB, ComCtrls, ExtCtrls, DBCGrids;
type
TForm1 = class(TForm)
DBCtrlGrid1: TDBCtrlGrid;
Table1: TTable;
DataSource1: TDataSource;
Table1Name: TStringField;
Table1Capital: TStringField;
Table1Continent: TStringField;
Table1Area: TFloatField;
Table1Population: TFloatField;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
Label1: TLabel;
Label2: TLabel;
Panel1: TPanel;
TrackBar1: TTrackBar;
LabelCols: TLabel;
procedure TrackBar1Change(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
LabelCols.Caption := Format (
'%d Columns', [TrackBar1.Position]);
DBCtrlGrid1.ColCount := TrackBar1.Position;
DBCtrlGrid1.Width := ClientWidth;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
DBCtrlGrid1.RowCount :=
(ClientHeight - Panel1.Height) div 100;
DBCtrlGrid1.Height := ClientHeight - Panel1.Height;
DBCtrlGrid1.Width := ClientWidth;
end;
end.
MULTIREC.DFM
object Form1: TForm1
Left = 260
Top = 193
Width = 443
Height = 342
Caption = 'Multi Record Grid'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
OnResize = FormResize
PixelsPerInch = 96
TextHeight = 13
object DBCtrlGrid1: TDBCtrlGrid
Left = 0
Top = 41
Width = 436
Height = 272
ColCount = 2
DataSource = DataSource1
PanelHeight = 136
PanelWidth = 210
TabOrder = 0
RowCount = 2
SelectedColor = clTeal
object Label1: TLabel
Left = 8
Top = 9
Width = 39
Height = 13
Caption = 'Country:'
end
object Label2: TLabel
Left = 8
Top = 52
Width = 35
Height = 13
Caption = 'Capital:'
end
object DBEdit1: TDBEdit
Left = 8
Top = 25
Width = 137
Height = 21
DataField = 'Name'
DataSource = DataSource1
TabOrder = 0
end
object DBEdit2: TDBEdit
Left = 8
Top = 68
Width = 137
Height = 21
DataField = 'Capital'
DataSource = DataSource1
TabOrder = 1
end
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 436
Height = 41
Align = alTop
TabOrder = 1
object LabelCols: TLabel
Left = 16
Top = 13
Width = 49
Height = 13
Caption = '2 Columns'
end
object TrackBar1: TTrackBar
Left = 80
Top = 8
Width = 161
Height = 26
Max = 8
Min = 2
Orientation = trHorizontal
PageSize = 1
Frequency = 1
Position = 2
SelEnd = 0
SelStart = 0
TabOrder = 0
TabStop = False
ThumbLength = 20
TickMarks = tmBottomRight
TickStyle = tsAuto
OnChange = TrackBar1Change
end
end
object Table1: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'COUNTRY.DB'
Left = 256
Top = 8
object Table1Name: TStringField
FieldName = 'Name'
Size = 24
end
object Table1Capital: TStringField
FieldName = 'Capital'
Size = 24
end
object Table1Continent: TStringField
FieldName = 'Continent'
Size = 24
end
object Table1Area: TFloatField
FieldName = 'Area'
end
object Table1Population: TFloatField
FieldName = 'Population'
end
end
object DataSource1: TDataSource
DataSet = Table1
Left = 312
Top = 8
end
end
|