STR:='0000000000000000';
if Checkbox1=True then
   STR[1]:='1'
else
   STR[1]:='0';if Checkbox2=True then
   STR[2]:='1'
else
   STR[2]:='0';......

解决方案 »

  1.   

    應該在確定時寫吧;
    xiaopachong(小爬虫) 這種辦法就行
      

  2.   

    1. 用CheckListBox控件,最简单。在Items里面设置16个项,即16个CheckBox,默认序号(Index)为0-15
    for i:=0 to 15 do
     if CheckListBox1.Checked[i] then Str[i]:=1
      else Str[i]:=0;2. var i:integer;
       tmpStr:string;
    begin
    for i:=1 to 16 do
     tmpStr:='CheckBox'+IntToStr(i);
     if (FindComponent(tmpStr) is TCheckBox) then
      if (FindComponent(tmpStr) as TCheckBox).Checked then
       Str[i]:=1;
    end;
      

  3.   

    对不起,写掉了一对begin... end:
    for i:=1 to 16 do
     begin
     tmpStr:='CheckBox'+IntToStr(i);
     if (FindComponent(tmpStr) is TCheckBox) then
      if (FindComponent(tmpStr) as TCheckBox).Checked then
       Str[i]:=1;
     end;
    end;