We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

FieldChooser and saving new layout of selected columns

Thread ID:





131026 Jun 16,2017 06:15 PM UTC Jun 19,2017 09:30 AM UTC WinForms 1
Tags: GridGroupingControl
Josip Pejakovic
Asked On June 16, 2017 06:15 PM UTC


Is it possible to save new layout of visible columns after using FieldChooser?
I want next time when user loads form to show only columns that he previously have been selected.

Arulpriya Ramalingam [Syncfusion]
Replied On June 19, 2017 09:30 AM UTC

Hi Josip, 

Thanks for using Syncfusion products. 

Is it possible to save new layout of visible columns after using FieldChooser?  
I want next time when user loads form to show only columns that he previously have been selected. 
Suggestion 1 
The GridGroupingControl does not have the direct support to maintain the previous visible columns when loading the Form. In order to save the Visible Columns and use it while loading the Form, Serialization and Deserialization can be used. Please refer to the below link to know more about Serialization and Deserialization. 
Please make use of below code and sample, 

//Event Triggering 
this.FormClosing += Form1_FormClosing; 
//Event Customization 
private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
     //To serialize the GridConditionalFormatDescriptor to  XML file 
     XmlWriter writer = XmlWriter.Create("VisibleColumnsSchema.xml"); 
this.Load += Form1_Load; 
//Event Customization 
private void Form1_Load(object sender, EventArgs e) 
     //DeSerialize the XML file to GridConditionalFormatDescriptorColloction 
     FileDialog dlg = new OpenFileDialog(); 
     dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; 
     if (dlg.ShowDialog() == DialogResult.OK) 
         XmlReader xr = new System.Xml.XmlTextReader(dlg.FileName); 
         //Apply the conditional formats. 
Suggestion 2 
In order to save the Visible columns collection before changing the datasource or refreshing the grid in FieldChooser, VisibleColumns.Changed event can be used.Please make use of below code and sample, 

//Event Triggering 
this.gridGroupingControl1.TableDescriptor.VisibleColumns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(VisibleColumns_Changed); 
private List<string> columns = new List<string>(); 
//Event Customization 
private void VisibleColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e) 
               if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Remove) 
                              string columnName = ((GridVisibleColumnDescriptor)e.Item).Name; 
                              if (! (columns.Contains(columnName))) 
//To refresh the grid 
private void refreshBtn_Click(object sender, EventArgs e) 
               this.gridGroupingControl1.DataSource = null; 
               this.gridGroupingControl1.DataSource = dataSource; 
               foreach (string name in columns) 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon