全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1427
推到 Plurk!
推到 Facebook!

關於 DBRadioGroup onClick 問題?

尚未結案
JuliusChen
一般會員


發表:13
回覆:8
積分:4
註冊:2005-06-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-19 11:06:27 IP:220.134.xxx.xxx 未訂閱
請教各位前輩: 我在 DBRadioGroup 的 click 上面寫了一段程式, 我希望他點了之後馬上生效,但事實並非如此, 我覺得他好像在 onExit 才生效... 程式碼如下: procedure Tfrm_code.DBR_CodeIDClick(Sender: TObject); begin if dstMaster.FieldByName('CodeID').AsString = '03' then Begin lbKind.Visible := true; dbcKind.Visible := true; end else begin lbKind.Visible := false; dbcKind.Visible := false; end; End; 我有試著把判斷式改為 if DBR_CodeID.Buttons[2].Checked Then 或者 if DBR_CodeID.ItemIndex = 2 then 但是都沒辦法在我點了 RedioButton 後馬上生效.. 不知和解? 謝謝!!
cashxin2002
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-08-19 11:57:00 IP:202.62.xxx.xxx 未訂閱
您好﹗    將程式碼寫在DBRadioGroup元件的OnChange事件中﹒    ================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟
JuliusChen
一般會員


發表:13
回覆:8
積分:4
註冊:2005-06-29

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-08-19 14:05:49 IP:220.134.xxx.xxx 未訂閱
您好: procedure Tfrm_code.DBR_CodeIDChange(Sender: TObject); begin if dstMaster.FieldByName('CodeID').AsString = '03' then Begin lbKind.Visible := true; dbcKind.Visible := true; end else begin lbKind.Visible := false; dbcKind.Visible := false; end; end; 依樣無效,判斷是我也換成 Button or ItemIndex, 但結果都依樣. 我在 RedioButton 上每個按鈕輪流click , 但只有在 onExit 才有效,我希望是在 onClick 有效... 謝謝!!
malanlk
尊榮會員


發表:20
回覆:694
積分:577
註冊:2004-04-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-08-19 15:33:27 IP:203.69.xxx.xxx 未訂閱
procedure Tfrm_code.DBR_CodeIDClick(Sender: TObject);
begin
  if DBR_CodeID.Value = '03' then
  Begin
    lbKind.Visible := true;
    dbcKind.Visible := true;
  end
  else
  begin
    lbKind.Visible := false;
    dbcKind.Visible := false;
  end;
end;
這樣應該可以, 原先的寫法是用 dstMaster.FieldByName('CodeID').AsString 來判斷, 可是 DBR_CodeID 要等到 OnExit 才會將資料異動...
JuliusChen
一般會員


發表:13
回覆:8
積分:4
註冊:2005-06-29

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-08-19 16:16:25 IP:220.134.xxx.xxx 未訂閱
您好: 試過還是不行.. 我在程式一開始的地方加了一行 showmessage(DBR_CodeID.value); 發覺一個現象.. 這個 message 是在我 focus 離開時才show , 不是我在 click 時 show. 我去檢查我的 even ,確實是在 onClick 的地方... 不知何解? 謝謝!!
malanlk
尊榮會員


發表:20
回覆:694
積分:577
註冊:2004-04-19

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-08-19 16:44:01 IP:203.69.xxx.xxx 未訂閱
Sorry! 忘了! 應該改用 OnChange... 不要用 ShowMessage, 當Message Box 出現, Focus 就跑掉了... 如果要看 DBR_CodeID.Value 的值, 可以加個 Break point 或 用 Caption := DBR_CodeID.Value; 觀察 Form 的 Title 有無變化, 你可以去看 Help, 對 Value, Field, 及 Items 的值有詳細解說 To add radio buttons to a TDBRadioGroup, edit the Items property in the Object Inspector. Each string in Items makes a radio button appear in the group box with the string as its caption. When the user selects a radio button, the "Value" of the selected button becomes the contents of the linked field for the current record in the dataset. Specify values for the buttons by editing the Values property in the Object Inspector; the first string in Values corresponds to the first string in Items, and so forth. If no Values strings are set, each button? caption serves as its value.
deity
尊榮會員


發表:90
回覆:876
積分:678
註冊:2003-05-09

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-08-19 16:44:27 IP:218.15.xxx.xxx 未訂閱
不好意思,插个花 JuliusChen您好: 小弟试了下,不管将代码写至onClick事件或onChange事件,都能很好的工作。  
这里是测试码
begin
  if DBRadioGroup1.ItemIndex =2 then
    showmessage('checked');
end;
1、if dstMaster.FieldByName('CodeID').AsString = '03' then 您的确定dstMaster中CodeID栏位值定位在等于03吗?默认是dstMaster的第一笔,如果第一笔CodeID栏位值不等于03,那下面的代码也不会执行。 2、建议采用DBRadioGroup1.ItemIndex =2方式。小弟测了没您所说的情况,会不会是您其它事件有干扰到,检查下各属性设置,建议拉一个新Form和DBRadioGroup进行测试? 3、if DBR_CodeID.Buttons[2].Checked Then 没这种写法吧? 4、如果还是无法解决,可以放至会员求助区,这样可能会更快的找出问题所在。 ============================ 为什么经过多年以后,得失的过程如此冷漠 ============================
系統時間:2024-07-03 5:30:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!