請教:在多個Checkbox中,如何選擇一個在EDIT中顯示一個,並且用分號隔開?

解决方案 »

  1.   

    苯方法:
      在每个CHECKBOX的ONCLICK事件中写类似这样的代码:
    if a.Checked then
     edit1.Text:=edit1.Text+a.Caption+';';
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        ComboBox1: TComboBox;
        Edit1: TEdit;
        procedure ComboBox1Select(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ComboBox1Select(Sender: TObject);
    begin
        if edit1.text='' then
          Edit1.Text:=ComboBox1.text
          else
        Edit1.Text:=Edit1.Text+','+ComboBox1.text;
    end;end.
      

  3.   

    to IOF:
      謝謝,你的辦法是可以,但是我的checkbox有30個呢,有更好的辦法嗎?
    to SDLIUBO:
       用ComboBox1可以,但是如果我選中以後又想取消呢,所以我選擇用checkbox。請指教。
      

  4.   

    1。写一个子程序:
    if TCHECKBOX(SENDER).Checked then
     edit1.Text:=edit1.Text+TCHECKBOX(SENDER).Caption+';';在每个CHECKbox中间调用。
    2。在groupbox.ONCHANGE中写事件也可以。