讨论将不同类型的非数据响应控件与数据集相连........ (0分)

  • 主题发起人 主题发起人 p_jz
  • 开始时间 开始时间
P

p_jz

Unregistered / Unconfirmed
GUEST, unregistred user!
将DataTimePicker,Label(举例)等组件与数据集相连,如何设计好的
类层次来来方便的达到此目的(不要说下载某个组件)?
请大家讨论下面的设计。
1, Name: TcustDataAware
Intent: Get and Set the specific property value of a component;
Structure: TcustDataAware = class;
Private
FfieldName: String;
Public
Procedure SetFieldName (Value: String);
Function GetPropertyValue: Variant; Virtual;
Procedure SetPropertyValue (Value: Variant); Virtual;
Property
FieldName: String read FfieldName write SetPropertyValue;
End;
2, Name: TCustDataCtrl:
Intent: In order to Initial the new record or to implement some common process.
Structure: TcustDataCtrl = Class
Private
FDataSet: TclientDataSet;
Procedure BindDataAware;
Procedure UnBindDataAware;
Protected
Procedure NewRecord(DataSet: TdataSet); Virtual;
Procedure BeforePost(DataSet: TdataSet); Virtual;
Procedure AfterPost(DataSet: TdataSet); Virtual;
Procedure AfterScroll(DataSet: TdataSet); Virtual;
Procedure SetEditable; Virtual;
Public
Procedure SetDataSet(Value: TclientDataSet);
Constructor Create(Owner: Tcomponent); Override; Virtual;
Destructor Destroy; Override; Virtual;
Property
DataSet: TclientDataSet read FdataSet write SetDataSet;
End;
Implementation
Procedure TcustDataCtrl.BindDataAware;
Begin
FdataSet.OnNewRecord := NewRecord;
FdataSet.BeforePost := BeforePost;
FdataSet.AfterPost := AfterPost;
FdataSet.AfterScroll := AfterScroll;
End;
Procedure TcustDataCtrl.UnBindDataAware;
Begin
FdataSet.OnNewRecord := Nil;
FdataSet.BeforePost := Nil;
FdataSet.AfterPost := Nil;
FdataSet.AfterScroll := Nil;
End;
Procedure TcustDataCtrl.NewRecord (DataSet: TdataSet);
Begin

End;
Procedure TcustDataCtrl.BeforePost (DataSet: TdataSet);
Begin

End;
Procedure TcustDataCtrl.AfterPost (DataSet: TdataSet);
Begin

End;
Procedure TcustDataCtrl.AfterScroll (DataSet: TdataSet);
Begin

End;
Procedure TcustDataCtrl.SetEditable ;
Begin

End;
Constructor Create (Owner: Tcomponent);
Begin
Inherited;
BindDataAware;
End;
Destructor Destroy ;
Begin
Inherited;
UnBindDataAware;
End;
3, Name: TcustVdataCtrl;
Intent: In order to make the DataSet and the visual components interact perfectly together .
Structure: TcustVdataCtrl = Class (TcustDataCtrl)
Private
FdataAwareList: Tlist;
Public
Procedure RegistDataAware (CustDataAware: TcustDataAware);
Procedure UnRegistDataAware (CustDataAware: TcustDataAware);
Constructor Create (Owner: Tcomponent); Override; Virtual;
Destructor Destroy; Override; Virtual;
End;
Implementation
Constructor Create (Owner: Tcomponent);
Begin
FdataAwareList := Tlist.Create (Self);
End;
Destructor Destroy ;
Begin
FdataAwareList.Free;
FdataAwareList := Nil;
End;
Procedure TcustVdataCtrl.RegistDataAware (CustDataAware: TcustDataAware);
Begin

End;
 
?????????[?][?][?][?][?]
 

Similar threads

I
回复
0
查看
549
import
I
I
回复
0
查看
680
import
I
I
回复
0
查看
702
import
I
后退
顶部