unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Edit1: TEdit; ListBox1: TListBox; procedure ListBox1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ListBox1Click(Sender: TObject); var I :Integer; a :string; begin I :=ListBox1.ItemIndex; a :=ListBox1.Items[I]; Edit1.Text :=Edit1.Text + ListBox1.Items[I]; end;end.
procedure TForm1.btn1Click(Sender: TObject); var i: integer; s: string; begin s := ''; for i := 0 to chklst1.Count - 1 do begin if chklst1.Checked[i] then begin s := s + chklst1.Items.Strings[i]; end; end; edt1.Text := s; end;
procedure TForm1.Button1Click(Sender: TObject); var i: integer; s: string; begin for i := 0 to CheckListBox1.Items.Count - 1 do if CheckListBox1.Checked[i] = true then s := s + CheckListBox1.Items.Strings[i]; edit1.Text := s; end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
ListBox1: TListBox;
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ListBox1Click(Sender: TObject);
var
I :Integer;
a :string;
begin
I :=ListBox1.ItemIndex;
a :=ListBox1.Items[I];
Edit1.Text :=Edit1.Text + ListBox1.Items[I];
end;end.
procedure TForm1.btn1Click(Sender: TObject);
var
i: integer;
s: string;
begin
s := '';
for i := 0 to chklst1.Count - 1 do
begin
if chklst1.Checked[i] then
begin
s := s + chklst1.Items.Strings[i];
end;
end;
edt1.Text := s;
end;
var
i: integer;
s: string;
begin
for i := 0 to CheckListBox1.Items.Count - 1 do
if CheckListBox1.Checked[i] = true then
s := s + CheckListBox1.Items.Strings[i];
edit1.Text := s;
end;
SmallHand 大哥!我采用了你的做法!不错!不过不写循环可以的吗?