请问各位大虾DataSource1DataChange和DataSource1UpdateData的区别 谢谢

lxwin2008 2003-08-22 04:32:37
谢谢了
...全文
87 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
michaelpeng7799 2003-08-23
  • 打赏
  • 举报
回复
要授人以道。

告诉你一个非常非常简单但很好的方法:当你不知哪个事件在什么时间发生时,可是在那个事件的事件过程中加一个显示,比如加个showmessage('Event!!!'),这样就很容易知道了,而且多个事件还能知道顺序。
lxpbuaa 2003-08-22
  • 打赏
  • 举报
回复
DataChange在下列两种情况下触发:
1、记录滚动(即使数据并没有并修改)
2、某个字段的数据被修改

当数据被修改后开始提交但还没有更新到数据库前,触发UpdateData。通常是TDataSet.Post会激发它。

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
DJ_KK 2003-08-22
  • 打赏
  • 举报
回复
DataChange代表你这个数据在改动,但是并不代表你现在就要提交。

UpdateData是你要告诉数据库,我想让这个改动的数据归入库里,也就是提交完成。

chl_ccssddnn 2003-08-22
  • 打赏
  • 举报
回复
DataSource1DataChange是处理datasource1的OndataChange事件的procedure
DataSource1UpdateData是处理datasource1的OnUpdateData事件的procedure。
具体区别,borland的原资料,我就不翻译了:
Write an OnUpdateData event handler to take specific actions prior to posting data changes to the database. If an application posts changes to the database and an OnUpdateData event handler exists, the handler is called before the dataset抯 Post method is executed. An OnUpdateData event handler might be useful for performing additional data processing or validation before posting


Write an OnDataChange event handler to take specific actions when a field in the current record has been edited and the application moves to another field, or when the current record in the associated dataset changes. OnDataChange is especially useful in applications that must synchronize data display in controls that are not data-aware. This event is typically used to make sure the control reflects the current field values in the dataset, because it is triggered by all changes.

Methods that can trigger this event include the Next or Prior methods for the dataset. Data-aware controls notify a data source of a data change when:

Scrolling to a new record.
Modifications to a field抯 data.

The Field parameter is nil if the change can affect more than one field value (for example when moving to a new record or refreshing a record buffer). If only one field is affected, Field indicates the edited field.
Cipherliu 2003-08-22
  • 打赏
  • 举报
回复
DataChange事件在记录移动时也会触发

UpdateData是在提交数据之前触发的

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧