//pas
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, CheckLst;type
TForm1 = class(TForm)
CheckListBox1: TCheckListBox;
BitBtnAllSelect: TBitBtn;
BitBtnBack: TBitBtn;
BitBtnAllCancel: TBitBtn;
BitBtnOk: TBitBtn;
procedure BitBtnAllSelectClick(Sender: TObject);
procedure BitBtnOkClick(Sender: TObject);
procedure CheckListBox1DblClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtnAllSelectClick(Sender: TObject);
var
I: Integer;
begin
for I := 0 to Pred(CheckListBox1.Items.Count) do
if CheckListBox1.ItemEnabled[I] then
case TWinControl(Sender).Tag of
-1: CheckListBox1.Checked[I] := False;
00: CheckListBox1.Checked[I] := not CheckListBox1.Checked[I];
+1: CheckListBox1.Checked[I] := True;
end;
end;procedure TForm1.BitBtnOkClick(Sender: TObject);
var
I: Integer;
S: string;
begin
S := '';
for I := 0 to CheckListBox1.Items.Count - 1 do
if CheckListBox1.Checked[I] then
S := S + CheckListBox1.Items[I] + #13#10;
ShowMessage(S);
end;procedure TForm1.CheckListBox1DblClick(Sender: TObject);
begin
if TCheckListBox(Sender).ItemIndex < 0 then Exit;
TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex] :=
not TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex];
end;procedure TForm1.FormCreate(Sender: TObject);
begin
BitBtnAllSelect.Tag := 1;
BitBtnBack.Tag := 0;
BitBtnAllCancel.Tag := -1;
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 103
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object CheckListBox1: TCheckListBox
Left = 0
Top = 0
Width = 536
Height = 121
ItemHeight = 13
Items.Strings = (
'1'
'2'
'3'
'4'
'5'
'6'
'7')
TabOrder = 0
OnDblClick = CheckListBox1DblClick
end
object BitBtnAllSelect: TBitBtn
Tag = 1
Left = 119
Top = 232
Width = 75
Height = 25
Caption = '全选(&A)'
TabOrder = 1
OnClick = BitBtnAllSelectClick
end
object BitBtnBack: TBitBtn
Left = 191
Top = 232
Width = 75
Height = 25
Caption = '反选(&B)'
TabOrder = 2
OnClick = BitBtnAllSelectClick
end
object BitBtnAllCancel: TBitBtn
Tag = -1
Left = 253
Top = 232
Width = 75
Height = 25
Caption = '全消(&L)'
TabOrder = 3
OnClick = BitBtnAllSelectClick
end
object BitBtnOk: TBitBtn
Left = 313
Top = 232
Width = 75
Height = 25
Caption = '确定(&Y)'
TabOrder = 4
OnClick = BitBtnOkClick
end
end
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, CheckLst;type
TForm1 = class(TForm)
CheckListBox1: TCheckListBox;
BitBtnAllSelect: TBitBtn;
BitBtnBack: TBitBtn;
BitBtnAllCancel: TBitBtn;
BitBtnOk: TBitBtn;
procedure BitBtnAllSelectClick(Sender: TObject);
procedure BitBtnOkClick(Sender: TObject);
procedure CheckListBox1DblClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtnAllSelectClick(Sender: TObject);
var
I: Integer;
begin
for I := 0 to Pred(CheckListBox1.Items.Count) do
if CheckListBox1.ItemEnabled[I] then
case TWinControl(Sender).Tag of
-1: CheckListBox1.Checked[I] := False;
00: CheckListBox1.Checked[I] := not CheckListBox1.Checked[I];
+1: CheckListBox1.Checked[I] := True;
end;
end;procedure TForm1.BitBtnOkClick(Sender: TObject);
var
I: Integer;
S: string;
begin
S := '';
for I := 0 to CheckListBox1.Items.Count - 1 do
if CheckListBox1.Checked[I] then
S := S + CheckListBox1.Items[I] + #13#10;
ShowMessage(S);
end;procedure TForm1.CheckListBox1DblClick(Sender: TObject);
begin
if TCheckListBox(Sender).ItemIndex < 0 then Exit;
TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex] :=
not TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex];
end;procedure TForm1.FormCreate(Sender: TObject);
begin
BitBtnAllSelect.Tag := 1;
BitBtnBack.Tag := 0;
BitBtnAllCancel.Tag := -1;
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 103
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object CheckListBox1: TCheckListBox
Left = 0
Top = 0
Width = 536
Height = 121
ItemHeight = 13
Items.Strings = (
'1'
'2'
'3'
'4'
'5'
'6'
'7')
TabOrder = 0
OnDblClick = CheckListBox1DblClick
end
object BitBtnAllSelect: TBitBtn
Tag = 1
Left = 119
Top = 232
Width = 75
Height = 25
Caption = '全选(&A)'
TabOrder = 1
OnClick = BitBtnAllSelectClick
end
object BitBtnBack: TBitBtn
Left = 191
Top = 232
Width = 75
Height = 25
Caption = '反选(&B)'
TabOrder = 2
OnClick = BitBtnAllSelectClick
end
object BitBtnAllCancel: TBitBtn
Tag = -1
Left = 253
Top = 232
Width = 75
Height = 25
Caption = '全消(&L)'
TabOrder = 3
OnClick = BitBtnAllSelectClick
end
object BitBtnOk: TBitBtn
Left = 313
Top = 232
Width = 75
Height = 25
Caption = '确定(&Y)'
TabOrder = 4
OnClick = BitBtnOkClick
end
end
解决方案 »
- delphi ADOCONNECTION错误拦截
- 泛型问题
- 【【统计】】 统计下Delphi还有多少人,看到此帖的都来冒泡~~~~
- Borland是否还会推出Delphi的下一个版本呐?
- 小弟有一小问题请教。望各位大哥赐教!!--
- "一个菜鸟问题,如何判断ClientSocket连接成功?"问题已经解决了,请myling(阿德)来领分
- 告知一下100分送上:)
- 请问以下SQL语句怎样写?或者有没有其他方法。
- 请大虾们告诉小弟怎样把Access建的库中表的数据导出并保存为.txt格式,怎样导入.txt中的数据进库中的表,我用的是DBGrid控件。最好赋上源
- 我没有分,但我想请教
- 怎样给一批组件赋值?
- access的mdb数据库如何编程知道里面含有那几个表?
var
I, J: Integer;
begin
for I := CheckListBox1.Count - 1 downto 0 do
if CheckListBox1.Checked[I] then begin
J := CheckListBox2.Items.Add(CheckListBox1.Items[I]);
CheckListBox2.Checked[J] := True;
CheckListBox1.Items.Delete(I);
end;
end;