-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmListBox.pas
82 lines (66 loc) · 1.49 KB
/
mListBox.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
unit mListBox;
interface
uses
SysUtils, Classes, Controls, StdCtrls,
Variants, StrUtils,
mKeyValue;
type
TmListBox = class(TListBox)
private
FCampo: String;
FLista : TmKeyValueList;
procedure ClrLista;
procedure AddLista(const Value: TmKeyValue);
procedure SetLista(const Value: TmKeyValueList);
function GetValue: TmKeyValue;
procedure SetValue(const Value: TmKeyValue);
protected
public
constructor create(Aowner : TComponent); override;
published
property _Campo : String read FCampo write FCampo;
property _Lista : TmKeyValueList read FLista write SetLista;
property _Value : TmKeyValue read GetValue write SetValue;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Comps MIGUEL', [TmListBox]);
end;
{ TmListBox }
constructor TmListBox.create(Aowner: TComponent);
begin
inherited;
FLista := TmKeyValueList.Create;
end;
//--
procedure TmListBox.ClrLista;
begin
FLista.Clear;
Items.Clear;
end;
procedure TmListBox.AddLista(const Value: TmKeyValue);
begin
FLista.Add(Value);
Items.AddObject(Value.Display, Value);
end;
procedure TmListBox.SetLista(const Value: TmKeyValueList);
var
I : Integer;
begin
ClrLista;
with FLista do
for I := 0 to Count - 1 do
AddLista(Items[I]);
end;
//--
function TmListBox.GetValue: TmKeyValue;
begin
Result := FLista.Items[ItemIndex];
end;
procedure TmListBox.SetValue(const Value: TmKeyValue);
begin
ItemIndex := FLista.IndexOf(Value);
end;
end.