WPF DataGrid CellEditEnding - DataSet不更新直到行丢失焦点 [英] WPF DataGrid CellEditEnding - DataSet Not Updating Till Row Lost Focus

查看:408
本文介绍了WPF DataGrid CellEditEnding - DataSet不更新直到行丢失焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦细胞从编辑中失去焦点,我需要能够更新数据集的值。我知道当细胞失去焦点时(CellEditEnding),但问题是,实际更新它的上下文项目不会发生,直到焦点对该行实际发生。当只剩下一个项目时,这是一个巨大的问题,因为它可能永远不会失去焦点。



如何确保每次列编辑完成(CellEditEnding)时,该行的实际上下文会在那一点更新(不只是当行丢失时焦点)



提前感谢

解决方案

a href =http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.commitedit%28v=VS.100%29.aspx =noreferrer> DataGrid.CommitEdit 从您的 DataGrid.CellEditEnding 处理程序,一定要处理重入。



这是一篇博客文章,描述了这项技术:




I need to be able to update values of a dataset once a cell loses focus from editing. I know when the cell loses focus (CellEditEnding), but problem is, the actual updating of it's context item does not occur till focus on that row actually occurs. This becomes a huge issue when there is only one item left, since it may never lose focus.

How do I make sure that each time a column edit is complete (CellEditEnding), the actual context for that row is updated at that point (not just when the row loses focus)

Thanks in advance!

解决方案

You can use DataGrid.CommitEdit from your DataGrid.CellEditEnding handler, being sure to handle reentrancy.

Here's a blog article that describes the technique:

这篇关于WPF DataGrid CellEditEnding - DataSet不更新直到行丢失焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆