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);
posted @ 2010-12-27 15:12  xygao  阅读(753)  评论(0编辑  收藏  举报