public partial class Form1 : DevExpress.XtraEditors.XtraForm
{ /// <summary> /// 保存视图的布局到一个特定的XML文件。 /// </summary> string fileName = @"E:\XtraGrid_SaveLayoutToXML.xml"; /// <summary> /// grid调整宽度自动保存,下次启动保持原来的宽带; /// </summary> public Form1() { InitializeComponent(); }/// <summary>
/// 恢复一个视图的布局从一个特定的XML文件,加载grid调整布局宽度; /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { gridControl1.ForceInitialize(); // Restore the previously saved layout gridControl1.MainView.RestoreLayoutFromXml(fileName); // TODO: 这行代码将数据加载到表“hsCrDataSet.Activity”中。您可以根据需要移动或删除它。 this.activityTableAdapter.Fill(this.hsCrDataSet.Activity); }/// <summary>
/// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_FormClosing(object sender, FormClosingEventArgs e) { // Save the layout to an XML file //Saves a View's layout to a specific XML file. //保存视图的布局到一个特定的XML文件。 gridControl1.MainView.SaveLayoutToXml(fileName); } }