TcxGrid 中的值更改后如何触发事件处理程序?
我有一个 DevExpress TcxGrid,其 GridView 的 OnEditValueChanged 事件附加了一个事件处理程序,该事件应该汇总其中一列中的一些数据。 问题是,在更新值写入基础数据集之前,该事件在验证期间被触发。 我对 TcxGrid 不太熟悉。 有谁知道是否有办法在数据集更新后触发事件处理程序?
I've got a DevExpress TcxGrid, with an event handler attached to its GridView's OnEditValueChanged event that's supposed to summarize some data in one of the columns. Problem is, this event gets fired during validation, before the updated value has been written to the underlying dataset. I'm not too familiar with the TcxGrid. Does anyone know if there's a way to fire an event handler after the dataset has been updated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 DataSource.OnDataChange 事件怎么样?
What about using the DataSource.OnDataChange event?
我不确定这是否正是您所需要的,但我发现网格的 ImmediatePost 选项对于我需要更新摘要的情况非常有用 - 它隐藏在 cxView 的数据控制器属性下。 这使得网格就像电子表格一样 - 只要用户在单元格中按下 Enter 或 Tab,记录就会发布。 然后我可能会从数据集的 AfterPost 事件中触发我的总结事件?
(您可能已经知道这一点,但 gridview 本身内置了许多非常有用的汇总选项 - 查看列的 Summary 属性,并确保 ViewOptions 中的 ShowFooter 设置为 true - 因此,如果您的摘要是相对简单的总计或平均值或类似的,让网格来完成这一切并为您节省一些工作。)
I'm not sure if this is exactly what you need, but I have found the ImmediatePost option of the grid to be very useful for situations where I need to update a summary - it's buried under its Data Controller property of the cxView. This makes the grid act like a spreadsheet - as soon as the user presses enter or tab in a cell, the record gets posted. Then I would have my summarising event fire from the AfterPost event of the dataset, perhaps?
(You probably already know this but the gridview itself has a lot of very useful summarising options built into it - look at the Summary properties of the columns, and make sure ShowFooter is set to true in the ViewOptions - so if your summary is a relatively simple total or average or similar, let the grid do it all and save yourself some work.)
如果您使用cxDBTableView,则在cxGrid中使用cxTableView或cxDBTableView,
然后在cxDBTableView属性中链接数据源的datasource.onchange中设置事件。 (cxDBTableView.datacontroller.datasource)
Do you use the cxTableView or cxDBTableView in the cxGrid
if you use the cxDBTableView then you set your event in the datasource.onchange of the linked datasource in the property of the cxDBTableView. (cxDBTableView .datacontroller.datasource)
我会选择 skamradt :更仔细地寻找符合您期望的活动。
否则,您可以在确保数据初始化后插入事件:
我强烈建议您不要将其用作常规开发习惯(通过代码使事件设置另一个回调是调试地狱的可靠方法),但是如果您实在找不到其他办法了...
I'd go with skamradt : look more carefully for an event which matches your expectations.
Otherwise, you can plug your event after making sure your data is initialized :
I would strongly advise you to NOT use this as a regular developping habbit (making an event set another callback through code is a sure way to debugging hell), but if you really don't find any other way to do it...