在一个FORM中
有一个EDIT,和一个CheckListbox,
问,怎么把CheckListbox选中的项(多选)放入到EDIT中?
这个可能是好简单的,但我就不会!
在线等!

解决方案 »

  1.   


    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.
      

  2.   


    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;
      

  3.   

    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;
      

  4.   

    lgx0914 大哥!我要的是checklistbox,不是LISTBOX!不过还是不错!学到不少东西!
    SmallHand 大哥!我采用了你的做法!不错!不过不写循环可以的吗?