c# - 如何重置 pivotGridControl 设置(DevExpress)?
问题描述
Сannot update 表格butReset_Click
不能RestoreLayoutFromRegistry
从另一个表格工作。怎么做才对?我从另一个表单创建了一个表单,有必要pivotGridControl
从 2 个表单重置设置。我无法重置设置。
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
butReset.Click += new System.EventHandler(butReset_Click);
pivotGridControl1.SaveLayoutToRegistry(regKey);
}
string regKey = "DevExpress\\XtraPivotGrid\\Layouts\\PivotGridLayout";
public Button butLoad = new Button();
public Button butReset = new Button();
public void LoadBtn_Click(object sender, EventArgs e)
{
Form1 fr = new Form1();
Form form = new Form();
form.Show();
ListBox listBox1 = new ListBox();
listBox1.Size = new System.Drawing.Size(200, 100);
listBox1.Location = new System.Drawing.Point(10, 10);
form.Controls.Add(listBox1);
listBox1.MultiColumn = true;
listBox1.SelectionMode = SelectionMode.MultiExtended;
DirectoryInfo dir = new DirectoryInfo(@"E:\");
FileInfo[] files = dir.GetFiles("*.txt");
butReset.Text = "Сбросить настройки";
butReset.Location = new Point(140, 160);
form.Controls.Add(butReset);
butLoad.Text = "Принять";
butLoad.Location = new Point(30, 160);
form.Controls.Add(butLoad);
var fileNamesWithoutExtension = files
.Select(fi => Path.GetFileNameWithoutExtension(fi.Name));
foreach (string fn in fileNamesWithoutExtension)
{
listBox1.Items.Add(fn.ToString());
}
}
private void SaveBtn_Click(object sender, EventArgs e)
{
pivotGridControl1.RestoreLayoutFromRegistry(regKey);
}
static public void butReset_Click(object sender, EventArgs e)
{
Form1 er = new Form1();
er.pivotGridControl1.RestoreLayoutFromRegistry(er.regKey);
//MessageBox.Show("dsdsdfsdf");
}
}
}
解决方案
使用PivotGridOptionsDataField.Reset()
方法将所有选项重置为其默认值。在你的情况下
static public void butReset_Click(object sender, EventArgs e)
{
pivotGridControl1.Reset();
}
参考文档:https ://docs.devexpress.com/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridOptionsDataField.Reset
推荐阅读
- swift - 将数据解码为 Struct 失败
- excel - 如何将 2 列与其他 2 列匹配
- javascript - 如何从 Javascript 中的 GWT 代码访问函数/变量?
- javascript - scrollIntoView onClick reactjs
- r - 将 MIN 和 MAX 组合成 R 中的 rowise 函数
- sql - 如何对字段求和
- javascript - Javascript 了解 PHP 何时改变了某些东西
- javascript - 使用 reactjs 进行服务器端渲染
- html - 表单无法包含语义 UI CDN
- angular - 我不能在 angular 上使用 http get 的结果