Hiding and Showing columns

I currently have a GridDataControl bound to a DataTable. I would like to allow the user to hide and show columns of their choosing. How can specify hidden and visible columns of the GridDataControl?

1 Reply

JJ Jeraldes J Syncfusion Team July 17, 2010 06:51 AM UTC

Hi Mike,
You can use the following code to add or remove column from the data table through code behind.

Remove Column:

var col = dataGrid.VisibleColumns.Where(d => d.MappingName == "Description").FirstOrDefault();
this.dataGrid.VisibleColumns.Remove(col);
this.dataGrid.Model.InvalidateVisual(true);

Add Column:

dataGrid.VisibleColumns.Add(new GridDataVisibleColumn() { MappingName = "Description" });


Regards,
Jeraldes J

Loader.
Up arrow icon