📄 listboxform.pas
字号:
unit ListBoxForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Buttons, EditForm, KsSkinForms, DB, ADODB,
KsSkinButtons, DBdata, KsSkinLabels, KsSkinGroupBoxs,
KsSkinListBoxs, BaseForm, KsSkinCheckBoxs, se_controls, ComCtrls,
ksskinstdcontrol, KsSkinSpeedButtons;
type
TfrmListBoxForm = class(TfrmEditForm)
Label1: TSeSkinLabel;
bbOk: TSeSkinButton;
bbNo: TSeSkinButton;
ListBox: TSeSkinListBox;
cbx1: TSeSkinCheckBox;
ListView: TSeSkinSListView;
procedure bbOkClick(Sender: TObject);
procedure bbNoClick(Sender: TObject);
procedure radio1Click(Sender: TObject);
procedure ListBoxDblClick(Sender: TObject);
procedure cbx1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ListViewDblClick(Sender: TObject);
private
sMemo, sStyle: string;
lType: Integer;
procedure LoadData;
procedure MainShow;
{ Private declarations }
public
{ Public declarations }
end;
function ListBoxFormShow(sCaption, s1Memo: string; l1Old: Integer; sStyle1: string = ''): Integer;
implementation
uses SysPublic;
{$R *.DFM}
function ListBoxFormShow(sCaption, s1Memo: string; l1Old: Integer; sStyle1: string = ''): Integer;
var
frmListBoxForm: TfrmListBoxForm;
begin
frmListBoxForm := TfrmListBoxForm.Create(Application); //新建窗体
with frmListBoxForm do
begin
Caption := sCaption;
sMemo := s1Memo;
lType := l1Old;
sStyle := sStyle1;
MainShow;
Result := lType;
Free;
end;
end;
procedure TfrmListBoxForm.MainShow;
begin
lType := -1;
Label1.Caption := Caption;
bOperateLog := False;
if sStyle = '' then sStyle := GetIniValue(frmData.ADOConnet, 'ListBoxStyle');
if sStyle = 'LISTBOX' then
cbx1.Checked := True
else
cbx1.Checked := False;
LoadData;
ShowModal;
end;
procedure TfrmListBoxForm.LoadData;
var
ListItem: TListItem;
i: integer;
begin
ListBox.Items.Text := sMemo;
if ListBox.Items.Count > 0 then ListBox.ItemIndex := 0;
if cbx1.Checked then
begin
ListBox.Visible := True;
ListView.Visible := False;
end
else
begin
ListBox.Visible := False;
ListView.Visible := True;
ListView.Items.Clear;
for i := 0 to ListBox.Items.Count - 1 do
begin
ListItem := ListView.Items.Add;
ListItem.Caption := Trim(ListBox.Items.Strings[i]);
ListItem.ImageIndex := 36;
end;
if ListView.Items.Count > 0 then ListView.ItemIndex := 0;
end;
end;
procedure TfrmListBoxForm.bbOkClick(Sender: TObject);
begin
if ListBox.Visible then
lType := ListBox.ItemIndex
else
lType := ListView.ItemIndex;
Close;
end;
procedure TfrmListBoxForm.bbNoClick(Sender: TObject);
begin
Close;
end;
procedure TfrmListBoxForm.radio1Click(Sender: TObject);
begin
inherited;
bbOkClick(Sender);
end;
procedure TfrmListBoxForm.ListBoxDblClick(Sender: TObject);
begin
inherited;
bbOkClick(Sender);
end;
procedure TfrmListBoxForm.cbx1Click(Sender: TObject);
begin
inherited;
LoadData;
end;
procedure TfrmListBoxForm.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
inherited;
if Cbx1.Checked then
sStyle := 'LISTBOX'
else
sStyle := '';
SetIniValue(frmData.ADOConnet, 'ListBoxStyle', sStyle);
end;
procedure TfrmListBoxForm.ListViewDblClick(Sender: TObject);
begin
inherited;
bbOkClick(Sender);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -