static public void gridviewLayoutRestoreFromXml(DevExpress.XtraGrid.Views.Grid.GridView _grid_view, String _xml_file_name) { if (null != _grid_view) { string layout_directory = System.Windows.Forms.Application.StartupPath + "\\" + LAYOUT_DIRECTORY_NM; // set need option _grid_view.OptionsLayout.Columns.StoreLayout = true; // check dirctory DirectoryInfo _dinfo = new DirectoryInfo(layout_directory); if (!_dinfo.Exists) { try { _dinfo.Create(); } catch (Exception) { return; } } // restore layout String layout_file_path = layout_directory + "\\" + _xml_file_name.Replace("./", ""); FileInfo _finfo = new FileInfo(layout_file_path); if (_finfo.Exists) { try { _grid_view.RestoreLayoutFromXml(layout_file_path); } catch (Exception) { } } } }
internal void CargarOGuardarDisenios(DevExpress.XtraGrid.Views.Grid.GridView control, bool guardar, string usuario, string nombreVista) { string direccion; if (guardar) { direccion = $@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\{control.Name}{nombreVista}{usuario}.xml"; control.SaveLayoutToXml(direccion); } else { direccion = $@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\{control.Name}{nombreVista}{usuario}.xml"; if (File.Exists(direccion)) { control.RestoreLayoutFromXml(direccion); } } }