求DevExpress.XtraGrid加载布局问题?

saibo528 2017-12-18 11:03:18
DevExpress.XtraGrid控件

求各位老大,为什么用这句加载布局不能起作用?
string fileName = "G:\\My Documents\\Visual Studio 2010\\Projects\\DevExpress1\\DevExpress1\\1.xml";
gridView1.RestoreLayoutFromXml(fileName);
...全文
251 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ajdkjalj 2017-12-20
  • 打赏
  • 举报
回复
你修改后保存xml了吗,没保存肯定加载的是之前的啊,你可以手动改了后打开xml看看是不是保存了
  • 打赏
  • 举报
回复
引用 4 楼 saibo528 的回复:
[quote=引用 1 楼 duanzi_peng 的回复:] 调用之前强制初始化,参见:https://documentation.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.BaseView.RestoreLayoutFromXml.method(mB9lhA)
不知道那里不对,就是行!!!~~~~[/quote] 先保存一遍,这句话: Use the RestoreLayoutFromXML method to load the View's layout previously saved to an XML file with the help of the SaveLayoutToXml method.
  • 打赏
  • 举报
回复
这是函数是保存上一次关闭前的Layout 吧。
saibo528 2017-12-20
  • 打赏
  • 举报
回复
不知道那里不对,就是不行不行不行,总是打少一个字.
saibo528 2017-12-20
  • 打赏
  • 举报
回复
不知道那里不对,就是行!!!~~~~
saibo528 2017-12-20
  • 打赏
  • 举报
回复
引用 1 楼 duanzi_peng 的回复:
调用之前强制初始化,参见:https://documentation.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.BaseView.RestoreLayoutFromXml.method(mB9lhA)
不知道那里不对,就是行!!!~~~~
lxgmag2016 2017-12-19
  • 打赏
  • 举报
回复
列没有添加到表格中去, 可以手动CODE,写入Columns.add(),这样就能显示出来了。
saibo528 2017-12-19
  • 打赏
  • 举报
回复
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加载到布局.???

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧