【原创】DevExpress控件GridControl中的布局详解
生活随笔
收集整理的這篇文章主要介紹了
【原创】DevExpress控件GridControl中的布局详解
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在進(jìn)行DevExpress控件GridControl的使用時(shí),因控件的靈活性,所以用戶會(huì)經(jīng)常進(jìn)行拖動(dòng)控件的列,以達(dá)到自己滿意的樣式,
但下次再打開時(shí)系統(tǒng)就會(huì)重新還原到原有的布局風(fēng)格,為了能夠保持用戶之前設(shè)置的風(fēng)格,下次再打開時(shí)依然保持原有的風(fēng)格。
在gridView中有兩個(gè)方法:SaveLayoutToXml(保存布局),RestoreLayoutFromXml(恢復(fù)布局)
?以下是具體的代碼:
private string systempath = "C:\\Program Files\\";/// <summary>
/// 保存風(fēng)格
/// </summary>
/// <param name="moduleid"></param>
/// <param name="saveType"></param>
private void SaveLayout(string moduleid, string saveType)
{
string path = systempath + "窗體風(fēng)格\\" + moduleid+"\\";
string file = saveType + "view.xml";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
m_gridView.SaveLayoutToXml(path+file);
}
/// <summary>
/// 加載風(fēng)格
/// </summary>
/// <param name="moduleid"></param>
/// <param name="saveType"></param>
private void LoadLayout(string moduleid, string saveType)
{
string path = systempath + "窗體風(fēng)格\\" + moduleid + "\\";
string file = saveType + "view.xml";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
if (!File.Exists(path + file))
return;
m_gridView.RestoreLayoutFromXml(path + file);
}
/// <summary>
/// 布局變化時(shí)產(chǎn)生事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void m_gridView_Layout(object sender, EventArgs e)
{
SaveLayout(m_controlManager.Owner.ModuleId, "Master");
}
/// <summary>
/// gridcontrol load Event
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void m_gridControl_Load(object sender, EventArgs e)
{
SaveLayout(m_controlManager.Owner.ModuleId, "Default");
LoadLayout(m_controlManager.Owner.ModuleId, "Master");
}
轉(zhuǎn)載于:https://www.cnblogs.com/martintuan/archive/2011/03/05/1971472.html
總結(jié)
以上是生活随笔為你收集整理的【原创】DevExpress控件GridControl中的布局详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: telnet小技巧
- 下一篇: mongodb小结(转)