-
Notifications
You must be signed in to change notification settings - Fork 1
/
ListUnit.pas
154 lines (136 loc) · 3.03 KB
/
ListUnit.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
unit ListUnit;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.IniFiles,
Data.DB,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.Objects,
FMX.Menus,
FMX.Grid,
FMX.ExtCtrls,
FMX.ListBox,
FMX.TreeView,
FMX.Memo,
FMX.TabControl,
FMX.Layouts,
FMX.Edit,
FMX.Platform,
FMX.Bind.DBEngExt,
FMX.Bind.Editors,
FMX.Bind.DBLinks,
FMX.Bind.Navigator,
Data.Bind.EngExt,
Data.Bind.Components,
Data.Bind.DBScope,
Data.Bind.DBLinks,
Datasnap.DBClient,
Fmx.Bind.Grid,
System.Rtti,
System.Bindings.Outputs,
Data.Bind.Grid,
Fmx.StdCtrls,
FMX.Header,
FMX.Graphics;
type
TListForm = class(TForm)
Panel1: TPanel;
btOK: TButton;
btCancel: TButton;
pnSearch: TPanel;
edSearchMask: TEdit;
edSearchMask_LBL: TLabel;
lvList: TListView;
procedure lvList2Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure edSearchMaskChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure lvList2DblClick(Sender: TObject);
procedure lvListColumnClick(Sender: TObject; Column: TListColumn);
private
prmName, prmID: integer;
procedure Search();
public
procedure Prepare(Text: string);
end;
var
ListForm: TListForm;
implementation
uses MyDataModule, Functions;
{$R *.FMX}
{ TListForm }
procedure TListForm.Prepare(Text: string);
var
i: integer;
begin
if Trim(Text)='' then Exit;
for i:=0 to lvList.Items.Count - 1 do
begin
if lvList.Items[i].Caption = Text then
begin
lvList.Selected:=lvList.Items[i];
lvList.Selected.MakeVisible(false);
Exit;
end;
end;
end;
procedure TListForm.Search;
var
i: integer;
begin
for i:=0 to lvList.Items.Count - 1 do
begin
if Pos(LowerCase(edSearchMask.Text), LowerCase(lvList.Items[i].SubItems[0])) > 0 then
begin
lvList.Selected:=lvList.Items[i];
lvList.Selected.MakeVisible(false);
Exit;
end;
end;
end;
procedure TListForm.lvList2Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
btOK.Enabled:=Assigned(lvList.Selected);
end;
procedure TListForm.lvList2DblClick(Sender: TObject);
begin
if Assigned(TJvListView(Sender).Selected) then ModalResult:=mrOk;
end;
procedure TListForm.lvListColumnClick(Sender: TObject; Column: TListColumn);
begin
if column.Index = 0 then
begin
lvList.CustomSort(@CustomIDSortProc, prmID);
prmID := -prmID;
end
else
begin
lvList.CustomSort(@CustomNameSortProc, prmName);
prmName := -prmName;
end;
end;
procedure TListForm.edSearchMaskChange(Sender: TObject);
begin
Search;
end;
procedure TListForm.FormCreate(Sender: TObject);
begin
prmName := 1;
prmID := 1;
dmMain.Translate.CreateDefaultTranslation(TForm(Self));
dmMain.Translate.TranslateForm(TForm(Self));
end;
procedure TListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if key = vk_escape then Close;
end;
end.