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

Notification的問題!

尚未結案
ucdesign2
一般會員


發表:24
回覆:33
積分:11
註冊:2002-10-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-09-09 17:27:50 IP:211.23.xxx.xxx 未訂閱
請教各位前輩: 在下寫了一個元件,其中有Connection的屬性(其作用與TAdoquery中的Connection屬性完全相同) 我的問題是在DesignTime時,當我貼上TADOConnection元件,而我的元件中的Connection的屬性也 指向此TADOConnection,如果我刪除TADOConnection元件,則會出現錯誤訊息! 請問要如何做到當我在DesignTime刪除TADOConnection元件時,能夠偵測到且把自定元件之 Connection屬性設為NIL?    以下為我的程式: unit AddrPanel1; interface uses   SysUtils, Classes, Controls, ExtCtrls,ComCtrls,DB,ADODB,Dialogs,StdCtrls,   Fashionpanel,Suibutton; type    TAddrPanel1 = class(TCustomPanel)   private     :     qry1,qry2,qry3:TADOQuery;     :     FAddrString:String;     FConnection:TADOConnection; procedure SetConnection(const Value: TADOConnection); protected public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property AddrString:String read FAddrString write SetAddrString; property Connection:TADOConnection read FConnection write SetConnection; end; procedure Register; implementation procedure Register; begin RegisterComponents('Custom', [TAddrPanel1]); end; { TAddrPanel1 } : : procedure TAddrPanel1.SetConnection(const Value: TADOConnection); begin FConnection:=Value; qry1.Connection:=Value; qry2.Connection:=Value; qry3.Connection:=Value; qry1.AfterScroll:=nil; qry1.SQL.Add('select * from 縣市資料'); : : end; end.
change.jian
版主


發表:29
回覆:620
積分:439
註冊:2003-06-02

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-09-09 17:43:10 IP:61.218.xxx.xxx 未訂閱
你要應用TComponent.FreeNotification及TComponent.Notification來解決這個問題,參考這裡 http://delphi.ktop.com.tw/topic.php?topic_id=29926 還有這篇 http://delphi.ktop.com.tw/topic.php?topic_id=24958 發表人 - change.jian 於 2004/09/09 17:51:41
ucdesign2
一般會員


發表:24
回覆:33
積分:11
註冊:2002-10-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-09-10 08:49:25 IP:211.23.xxx.xxx 未訂閱
謝謝change.jian版主再次相助!
系統時間:2024-05-17 10:57:12
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!