Delphi帮助中关于TDataSource的描述,它不仅联系DataSet与数据感应控件之间的联系,而且在Master/Detail表中提供两个DataSet之间的联系. TDataSource provides an interface between a dataset component and data-aware controls on a form.Description Use TDataSource to provide a conduit between a dataset and data-aware controls on a form that enable display, navigation, and editing of the data underlying the dataset. Link two datasets in a master/detail relationship.All datasets must be associated with a data source component if their data is to be displayed and manipulated in data-aware controls. Similarly, each data-aware control needs to be associated with a data source component in order for the control to receive and manipulate data.Data source components also link datasets in master-detail relationships.
它是接通DataSet与数据感应控件的桥梁~~~~~
你可以假设没有DataSource的情况~~~~~~~~~~~~~~~~~~~
因为你其它是不知道TDataSource内部作了些什么,从TDataSet里继承下面的提供数据的类是很多的,
它们最后输出的数据格式可能已经发生了变化,这时候如果要在第一个使用数据源的类作处理,如TDbgrid、Tdbedit....
那不好,用一个中间的TDataSource可以统一一种格式,这样的话,就很方便,
也许我们觉得它很浪费,也没有用,但其内部完成的功能确是我们不知道了。
TDataSource provides an interface between a dataset component and data-aware controls on a form.Description
Use TDataSource to
provide a conduit between a dataset and data-aware controls on a form that enable display, navigation, and editing of the data underlying the dataset.
Link two datasets in a master/detail relationship.All datasets must be associated with a data source component if their data is to be displayed and manipulated in data-aware controls. Similarly, each data-aware control needs to be associated with a data source component in order for the control to receive and manipulate data.Data source components also link datasets in master-detail relationships.
因为你其它是不知道TDataSource内部作了些什么,从TDataSet里继承下面的提供数据的类是很多的,
它们最后输出的数据格式可能已经发生了变化,这时候如果要在第一个使用数据源的类作处理,如TDbgrid、Tdbedit....
那不好,用一个中间的TDataSource可以统一一种格式,这样的话,就很方便,
也许我们觉得它很浪费,也没有用,但其内部完成的功能确是我们不知道了。
AddDataLink。
2.每当改变一个数据敏感控件的DataSource属性时,就会触发相应DataSource中的方法AddDataLink,往DataSource.FDataLinks中加上这个数据敏感控件,这样当数据集的数据发生变化时就会通知它。
不知道我这样说,各位大侠能否听明白。
2.当数据敏感控件的DataSource变化时,就会触发相应DataSource的方法AddDataLink,将该数据敏感控件注册到DataSource中,这样当数据集的数据变化时,就会通知这个数据敏感控件。
不知道我这样说,各位大侠是否听明白了
2.当数据敏感控件的DataSource变化时,就会触发相应DataSource的方法AddDataLink,将该数据敏感控件注册到DataSource中,这样当数据集的数据变化时,就会通知这个数据敏感控件。
不知道我这样说,各位大侠是否听明白了
起个路由的作用,这样可以只改变DataSource和DataSet之间的关系,就可以
让数据敏感控件显示不同数据集的数据
也可以保存TTable,Tquery做过一些数据过滤,查询后的结果.
比如说 tquery:tdatasourse 可为1:多
不同时候的查询结果,用不同的tdatasourse保存.可作为显示控件显示.
起个路由的作用,这样可以只改变DataSource和DataSet之间的关系,就可以
让数据敏感控件显示不同数据集的数据"to dtqyhq(鸿浪):
你讲到的这一点可能正是TDataSource存在的唯一理由.
但是如果直接设置数据可视组件的DataSet属性也可以,只是比较烦琐一些。
况且,这种方式一般用在数据比较通用的情况下,通常很少出现把可视组件的DataSet换来换取。大家可能遇到过这样的情况,在一个DataModule上放置了好多DataSet组件,同时可能还要放置同等数量的DataSource组件。累呀不累?
doc = dataset
view = dbgrid,dbedit...datasource起什么作用?
DataSource中有它们之间的共同特性,从这点角度看,它还是有存在的必要。
我感觉楼主的看法有道理,但没有tdadasource可能就会感到不方便
我感觉楼主的看法有道理,但没有tdadasource可能就会感到不方便
可恶,明天再试试!