DevExpress WPF Grid - 列宽度更改时的事件
有谁知道,当用户更改 WPF DevExpress 网格的列宽时会引发哪个事件?我想用它来存储数据库中的列宽度。
does anyone knows, which event is raised, when user changes width of column for WPF DevExpress grid? I want to use it to store columns widths in database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过事件 View.LostFocus 存储列宽:
DevExpress.Xpf.Grid.GridControl grc = new DevExpress.Xpf.Grid.GridControl();
grc.View.LostFocus += View_LostFocus;
并与处理程序:
You Can store columns widths by event View.LostFocus:
DevExpress.Xpf.Grid.GridControl grc = new DevExpress.Xpf.Grid.GridControl();
grc.View.LostFocus += View_LostFocus;
And with handler:
我也必须做同样的事情,但对于 silverlight 网格。我能得到的最好的结果是处理 Grid.LayoutUpdated 事件,并枚举列以获取它们的宽度。我什至无法绑定到 silverlight 网格中的列宽属性,因为它不是依赖属性,WPF 网格很可能完全相同。
编辑:
不过,您可以做的是检查 WPF 网格的源代码,并自己添加 ColumnResized 事件。这并不理想,因为每次安装 DevExpress 更新时都必须重新集成代码,然后重建网格。您还需要小心如何执行此操作,例如,您需要找出最佳方法来确定列大小调整何时完成,以便您不会不断触发该事件。或者您可以寻找一个功能更齐全(更成熟)的网格?
I've had to do the same, but for the silverlight grid. The best i could get was to handle the Grid.LayoutUpdated event, and enumerate the columns to get their widths. I couldn't even bind to the column width property in the silverlight grid because it wasn't a dependency property, the WPF grid is most likely exactly the same.
EDIT:
what you could do though is check through the source code of the WPF grid, and add a ColumnResized event yourself. It's not ideal, because you would have to re-integrate the code everytime you installed a DevExpress update, and then rebuild the grid. You would also need to be careful how you do it, for instance you need to work out the best way to determine when a column resize has finished, so that you don't continually fire the event. Or you could look round for a more fully featured (more mature) grid?
DataGridColumnHeader 公开了一个 SizeChanged 事件,该事件将 SizeChangedEventArgs 对象传递给您,其中公开了许多有用的尺寸信息!
The DataGridColumnHeader exposes a SizeChanged event which passes the SizeChangedEventArgs object to you in which a lot of useful Sizes info is exposed!