开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 2369|回复: 2

DevExpress加载布局?

[复制链接]

0

精华

787

贡献

61

赞扬

帖子
61
软币
839
在线时间
131 小时
注册时间
2016-2-27
发表于 2017-12-17 22:04:53 | 显示全部楼层 |阅读模式

求各位老大,为什么用这句加载布局不能起作用?
gridView1.RestoreLayoutFromXml("G:\\My Documents\\Visual Studio 2010\\Projects\\DevExpress1\\DevExpress1\\Layout11.xml"); //加载布局

回复

使用道具 举报

0

精华

787

贡献

61

赞扬

帖子
61
软币
839
在线时间
131 小时
注册时间
2016-2-27
 楼主| 发表于 2017-12-19 11:14:05 | 显示全部楼层
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Design;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid;

namespace DevExpress1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Columnadd();

            string fileName = @"G:\My Documents\Visual Studio 2010\Projects\DevExpress1\DevExpress1\1.xml";
            gridControl1.ForceInitialize();
            gridControl1.MainView.RestoreLayoutFromXml(fileName);
        }

        private void Columnadd()
        {
            GridColumn addColid = gridView1.Columns.AddField("col1");
            addColid.Caption = "列1";
            addColid.VisibleIndex = 0;

            GridColumn addColmIcon = gridView1.Columns.AddField("col2");
            addColmIcon.Caption = "列2";
            addColmIcon.VisibleIndex = 1;

            GridColumn addColm3 = gridView1.Columns.AddField("col3");
            addColm3.Caption = "列3";
            addColm3.VisibleIndex = 2;
        }

    }
}


为什么没有从xml加载到布局.???
回复

使用道具 举报

0

精华

0

贡献

0

赞扬

帖子
4
软币
99
在线时间
3 小时
注册时间
2017-4-23
发表于 2018-1-21 13:10:23 | 显示全部楼层
在 Restore之前加一句 ForceInitialize();

需要 Using Devexpress.XtraGrid;
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-3-28 16:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表