frm_list.pas
来自「站长您好」· PAS 代码 · 共 85 行
PAS
85 行
unit Frm_List;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Frm_Cargo, XPMenu, Buttons, EnterAsTab, GIFImage, ExtCtrls,
THPanel, StdCtrls, dxCore, dxButton, ImgList, ComCtrls;
type
TFrmList = class(TFrmCargo)
Lv: TListView;
ImageList1: TImageList;
procedure FormDeactivate(Sender: TObject);
procedure LvKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
Combobox: TCombobox;
function GetCmbIndex(Combobox: TCombobox; s: string): integer;
//输入Combobox.text值,如果存在则返回ItemIndex值,否则返回-1
{ Public declarations }
end;
var
FrmList: TFrmList;
implementation
{$R *.dfm}
function TFrmList.GetCmbIndex(Combobox: TCombobox; s: string): integer;
var
i: integer;
begin
for i := 0 to Combobox.Items.Count - 1 do
begin
if Combobox.Items[i] = trim(s) then
begin
result := i;
exit;
end;
end;
result := -1;
end;
procedure TFrmList.FormDeactivate(Sender: TObject);
begin
inherited;
Close;
end;
procedure TFrmList.LvKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Lv.Items.Count = 0 then
begin
FrmList.Close;
exit;
end;
Combobox.Clear;
Combobox.Items.Add(Lv.Selected.Caption);
Combobox.ItemIndex := 0;
FrmList.Close;
end;
procedure TFrmList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TFrmList.FormDestroy(Sender: TObject);
begin
inherited;
FrmList := nil;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?