線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:876
推到 Plurk!
推到 Facebook!

求助,怎么使一些 checkbox 受控制,一些 checkbox 不受控制呢?,谢谢!

答題得分者是:cashxin2002
lsh998
中階會員


發表:163
回覆:138
積分:60
註冊:2005-01-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-05-21 14:53:22 IP:219.128.xxx.xxx 未訂閱
procedure TClassKaoQinForm.Button1Click(Sender: TObject); var checkboxitems:integer; mustOndutyaDays:string; begin for checkboxitems:=2 to ClassKaoQinForm.componentcount-1 do begin if (ClassKaoQinForm.components[checkboxitems] is TCheckBox) and (TCheckBox(ClassKaoQinForm.components[checkboxitems]).Checked) then begin mustOndutyaDays:=mustOndutyaDays inttostr(TCheckBox(ClassKaoQinForm.components[checkboxitems]).Tag) '##'; end; end; end; 问题是:ClassKaoQinForm 有 8个 checkbox ,还很有多别窗体, 我希望 checkbox1 和 checkbox2 不受 procedure TClassKaoQinForm.Button1Click(Sender: TObject); var checkboxitems:integer; mustOndutyaDays:string; begin for checkboxitems:=2 to ClassKaoQinForm.componentcount-1 do begin if (ClassKaoQinForm.components[checkboxitems] is TCheckBox) and (TCheckBox(ClassKaoQinForm.components[checkboxitems]).Checked) then begin mustOndutyaDays:=mustOndutyaDays inttostr(TCheckBox(ClassKaoQinForm.components[checkboxitems]).Tag) '##'; end; end; end; 的控制,能不能实现啊? 像我上面的程序 checkbox1 和 checkbox2 是有可能受其控制的! 请各位大哥,教我一种方法啊? 谢谢!
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-05-21 15:44:53 IP:202.47.xxx.xxx 未訂閱
您好﹗    不懂為何要在迴圈中將起始值設為2﹐那樣就會遺漏檢查兩個元件了﹒改成如下試試﹕
procedure TClassKaoQinForm.Button1Click(Sender: TObject);
var
  checkboxitems:integer;
  mustOndutyaDays:string;
begin
  for checkboxitems:=0 to ClassKaoQinForm.componentcount-1 do
  begin
    if (ClassKaoQinForm.components[checkboxitems].ClassType=TCheckBox)
    and (TCheckBox(ClassKaoQinForm.component[checkboxitems]).Checked) 
    and (ClassKaoQinForm.components[checkboxitems].Name<>'CheckBox1')
    and (ClassKaoQinForm.components[checkboxitems].Name<>'CheckBox2')
    then
      begin
        mustOndutyaDays:=mustOndutyaDays+inttostr(TCheckBox(ClassKaoQinForm.components[checkboxitems]).Tag)+'##';
      end;
  end; 
end;
================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================ 發表人 - cashxin2002 於 2005/05/21 15:45:41
------
忻晟
lsh998
中階會員


發表:163
回覆:138
積分:60
註冊:2005-01-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-05-21 16:12:36 IP:219.128.xxx.xxx 未訂閱
cashxin2002 大哥: 您好! 您太热心了,也太牛了^_^ 小弟我刚毕业,非常菜,以后会常向大哥您请教的! 还问题大哥一个 题外的话题,cashxin2002 大哥,您是我们大陆, 还是宝岛台湾人氏^_^ 谢谢cashxin2002 大哥!
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-05-21 16:44:47 IP:202.47.xxx.xxx 未訂閱
lsh998您好﹗    我是上海人﹐目前在泰(寮)國就職﹒ 寫程式的開始是對這方面的興趣﹐我不是專科出生﹐所以連那個"牛"字真的是差太遠了﹐只是用唯一的熱心來回饋本站的資源﹐你很努力﹐加油﹗    ================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟
Arlung Miao
初階會員


發表:9
回覆:44
積分:25
註冊:2004-08-25

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-05-21 17:13:32 IP:59.40.xxx.xxx 未訂閱
var
  i: Integer;
  oTmp: TComponent;
  ...
begin
  ...
  with ClassKaoQinForm do begin
    for i := 0 to ComponentCount - 1 do begin
      oTmp := Components[i];
      if (oTmp is TCheckBox) and TCheckBox(oTmp).Checked then begin
        if (UpperCase(oTmp.Name) <> 'CHECKBOX1') 
           and (UpperCase(oTmp.Name) <> 'CHECKBOX2') then begin
          mustOndutyaDays:=mustOndutyaDays inttostr(TCheckBox(ClassKaoQinForm.components[checkboxitems]).Tag) '##';
        end;
      end;
    end;
  end;
lsh998
中階會員


發表:163
回覆:138
積分:60
註冊:2005-01-07

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-05-21 20:17:32 IP:219.128.xxx.xxx 未訂閱
谢谢 Arlung Miao 大哥和 cashxin2002 大哥! cashxin2002 大哥 泰国也用繁文啊 ^_^ 啊! 祝 cashxin2002 大哥 在异国过的好!
系統時間:2024-06-27 3:12:41
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!