【问题标题】:How to reset pivotGridControl settings (DevExpress)?如何重置 pivotGridControl 设置(DevExpress)?
【发布时间】:2021-06-03 18:59:03
【问题描述】:

Сannot 更新表单 butReset_Click 不起作用 RestoreLayoutFromRegistry 从另一个表单。怎么做才对?我从另一个表单创建了一个表单,有必要从 2 个表单重置 pivotGridControl 设置。我无法重置设置。

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");
    
            }
    
        }
    }

【问题讨论】:

    标签: c# winforms devexpress


    【解决方案1】:

    使用PivotGridOptionsDataField.Reset() 方法将所有选项重置为其默认值。你的情况

    static public void butReset_Click(object sender, EventArgs e)
    {
        pivotGridControl1.Reset();
    }
    

    参考文档:https://docs.devexpress.com/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridOptionsDataField.Reset

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多