6 Windows
, Classes
, Messages
, Forms
, SysUtils
,
11 TListEditColumns
= class;
13 TKOLListEdit
= class(TKOLListView
)
15 fColumns
: TListEditColumns
;
19 function AdditionalUnits
: string; override;
20 procedure SetupFirst( SL
: TStringList
; const AName
, AParent
, Prefix
: String ); override;
21 procedure SetupLast( SL
: TStringList
; const AName
, AParent
, Prefix
: String ); override;
22 procedure AssignEvents( SL
: TStringList
; const AName
: String ); override;
23 function GetCaption
: string;
24 function GetStyle
: TKOLListViewStyle
;
25 function GetOptions
: TKOLListViewOptions
;
26 procedure SetOptions(v
: TKOLListViewOptions
);
27 function GetColumns
: TListEditColumns
; virtual;
28 procedure SetColumns(v
: TListEditColumns
);
29 function GetColCount
: integer;
30 procedure SetColCount(v
: integer);
32 constructor Create(Owner
: TComponent
); override;
33 property IsListData
: boolean read fListData write fListData
;
34 procedure UpdateColumns
; virtual;
36 property Caption
: string Read GetCaption
;
37 property Style
: TKOLListViewStyle Read GetStyle
;
38 property Options
: TKOLListViewOptions read GetOptions write SetOptions
;
39 property Columns
: TListEditColumns read fColumns write SetColumns
;
40 property ColCount
: integer read GetColCount write SetColCount
;
43 TListEditColumnsItem
= class(TCollectionItem
)
50 procedure SetAlignment(a
: TAlignment
);
51 procedure SetCaption(c
: string);
52 procedure SetWidth(w
: integer);
54 property Alignment
: TAlignment read fAlign write fAlign
;
55 property Caption
: string read fCaption write fCaption
;
56 property Width
: integer read fWidth write fWidth
;
57 property FieldName
: string read fFieldName write fFieldName
;
60 TListEditColumns
= class(TCollection
)
63 function GetItem(Index
: Integer): TListEditColumnsItem
;
64 procedure SetItem(Index
: Integer; Value
: TListEditColumnsItem
);
66 function GetOwner
: TPersistent
; override;
68 FieldNames
: TStringList
;
69 constructor Create(AOwner
: TKOLListEdit
);
70 destructor Destroy
; override;
71 function Owner
: TKOLListEdit
;
72 property Items
[Index
: Integer]: TListEditColumnsItem read GetItem write SetItem
; default
;
81 constructor TKOLListEdit
.Create
;
84 inherited Style
:= lvsDetail
;
85 inherited Options
:= [lvoRowSelect
];
86 Font
.FontCharset
:= 204;
87 fColumns
:= TListEditColumns
.Create(self
);
90 procedure TKOLListEdit
.UpdateColumns
;
95 function TKOLListEdit
.AdditionalUnits
;
97 Result
:= ', ListEdit';
100 procedure TKOLListEdit
.SetupFirst
;
105 for i
:= 0 to fColumns
.Count
- 1 do begin
106 case fColumns
.Items
[i
].Alignment
of
107 taLeftJustify
: s
:= 'taLeft';
108 taCenter
: s
:= 'taCenter';
109 taRightJustify
: s
:= 'taRight';
111 SL
.Add( Prefix
+ AName
+ '.LVColAdd(''' + fColumns
.Items
[i
].Caption
+ ''',' + s
+ ' , ' + intTostr(fColumns
.Items
[i
].Width
) + ');' );
115 procedure TKOLListEdit
.SetupLast
;
117 inherited AssignEvents(SL
, AName
);
120 procedure TKOLListEdit
.AssignEvents
;
125 function TKOLListEdit
.GetCaption
;
127 Result
:= inherited Caption
;
130 function TKOLListEdit
.GetStyle
;
135 function TKOLListEdit
.GetOptions
;
137 Result
:= inherited Options
;
140 procedure TKOLListEdit
.SetOptions
;
142 inherited Options
:= v
+ [lvoRowSelect
];
145 function TKOLListEdit
.GetColumns
;
150 procedure TKOLListEdit
.SetColumns
;
156 function TKOLListEdit
.GetColCount
;
158 Result
:= fColumns
.Count
;
161 procedure TKOLListEdit
.SetColCount
;
164 if fColCount
< 0 then fColCount
:= 0;
165 while fColCount
> fColumns
.Count
do fColumns
.Add
;
166 while fColCount
< fColumns
.Count
do fColumns
[fColumns
.Count
- 1].Free
;
170 procedure TListEditColumnsItem
.SetAlignment
;
173 TListEditColumns(GetOwner
).FOwner
.Change
;
176 procedure TListEditColumnsItem
.SetCaption
;
181 procedure TListEditColumnsItem
.SetWidth
;
186 constructor TListEditColumns
.Create
;
188 inherited create(TListEditColumnsItem
);
190 FieldNames
:= TStringList
.Create
;
193 destructor TListEditColumns
.Destroy
;
199 function TListEditColumns
.GetItem
;
201 result
:= TListEditColumnsItem(inherited GetItem(Index
));
204 procedure TListEditColumns
.SetItem
;
206 inherited SetItem(Index
, Value
);
210 function TListEditColumns
.GetOwner
;
215 function TListEditColumns
.Owner
;
222 RegisterComponents('KOLUtil', [TKOLListEdit
]);