右键弹出配置表格菜单:增加<还原预设配置>功能
右键弹出配置表格菜单:增加<还原预设配置>功能
当我们配置了表格列的样式,比如列的宽度、位置后又想还原为原始状态,于是增加<还原预设配置>功能。
当我们配置了表格列的样式,比如列的宽度、位置后又想还原为原始状态,于是增加<还原预设配置>功能。
代码实现:
1. 在CSFramework.Library.frmGridCustomize.OnShowGridMenu方法内增加一行代码:
2. menuItemRestoreGridConfig_Click 事件
2.DeleteGridConfig方法
扫一扫加微信
1. 在CSFramework.Library.frmGridCustomize.OnShowGridMenu方法内增加一行代码:
C# Code:
/// <summary>
/// 在表格内点右键弹出菜单(菜单自动创建)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnShowGridMenu(object sender, GridMenuEventArgs e)
{
.........省略..........
CreatePopupMenuItem(rowMenu, "还原预设配置",
Globals.LoadImage("cslogo16.ico"), menuItemRestoreGridConfig_Click, true);
.........省略..........
}
/// <summary>
/// 在表格内点右键弹出菜单(菜单自动创建)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnShowGridMenu(object sender, GridMenuEventArgs e)
{
.........省略..........
CreatePopupMenuItem(rowMenu, "还原预设配置",
Globals.LoadImage("cslogo16.ico"), menuItemRestoreGridConfig_Click, true);
.........省略..........
}
2. menuItemRestoreGridConfig_Click 事件
C# Code:
private static void menuItemRestoreGridConfig_Click(object sender, EventArgs e)
{
DXMenuItem item = sender as DXMenuItem;
GridView view = (GridView)item.Tag;
new GridConfig(view).DeleteGridConfig();
Msg.ShowInformation("已还原表格配置,请重新打开窗体。");
}
private static void menuItemRestoreGridConfig_Click(object sender, EventArgs e)
{
DXMenuItem item = sender as DXMenuItem;
GridView view = (GridView)item.Tag;
new GridConfig(view).DeleteGridConfig();
Msg.ShowInformation("已还原表格配置,请重新打开窗体。");
}
2.DeleteGridConfig方法
C# Code:
/// <summary>
/// 删除配置信息
/// </summary>
public void DeleteGridConfig()
{
if (!File.Exists(_XMLPath)) CreateXML();
_XMLDoc.Load(_XMLPath); //加载XML文件.
string srh = string.Format("Root/Grid[@Name='{0}']", _GridFullName);
XmlNode node = _XMLDoc.SelectSingleNode(srh);
if (node != null)
{
node.ParentNode.RemoveChild(node);
_XMLDoc.Save(_XMLPath);
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
/// <summary>
/// 删除配置信息
/// </summary>
public void DeleteGridConfig()
{
if (!File.Exists(_XMLPath)) CreateXML();
_XMLDoc.Load(_XMLPath); //加载XML文件.
string srh = string.Format("Root/Grid[@Name='{0}']", _GridFullName);
XmlNode node = _XMLDoc.SelectSingleNode(srh);
if (node != null)
{
node.ParentNode.RemoveChild(node);
_XMLDoc.Save(_XMLPath);
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc
C/S框架网