DEV EXPRESS中gridview的SaveLayoutToRegistry
今天在dev的community上看到一个问题,我也在做这个东西,顺便记录一下。问题网址:http://community.devexpress.com/forums/p/6281/26154.aspx
问题正文:
I'm using the GridView.SaveLayoutToRegistry and GridView.RestoreFromRegistry to save my gridview layouts after user customization (resizing or reordering of columns) and have a 3-level master-detail grid with 3 different gridviews at the lowest level (i.e. 5 separate gridviews). I'm calling the SaveLayoutToRegistry and RestoreFromRegistry on all 5 gridviews, but only the master view seems to restore the layout as expected. How do I get my child gridviews to also restore the saved layout? Rgds, JC
问题解决:
分别调用每一个level的gridview的SaveLayoutToRegistry()方法,例:
gridView1.SaveLayoutToRegistry(EPort.Class.Encrypt.strRegedit + this.Name + "gridView1");
gridView2.SaveLayoutToRegistry(EPort.Class.Encrypt.strRegedit + this.Name + "gridView2");
然后在恢复的时候也分别对每一个gridview进行恢复即可。
gridView1.RestoreLayoutFromRegistry(EPort.Class.Encrypt.strRegedit + this.Name + "gridView1");
gridView2.RestoreLayoutFromRegistry(EPort.Class.Encrypt.strRegedit + this.Name + "gridView2");
附上dev documentation网站的Examples:
The following example saves the layout of the GridControl.MainView to the system registry and then restores it. The full path for the layout in the registry will be:HKEY_CURRENT_USER\DevExpress\XtraGrid\Layouts\MainLayout
string regKey = "DevExpress\\XtraGrid\\Layouts\\MainLayout"; gridControl1.MainView.SaveLayoutToRegistry(regKey); //... gridControl1.MainView.RestoreLayoutFromRegistry(regKey);
作者:xygao
出处:http://www.cnblogs.com/xygao/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。