AD
Administrator
Syncfusion Team
January 31, 2007 12:03 AM UTC
In a GridControl or GridDataBoundGrid, you can you code like:
grid.Model.Cols.Hidden[colIndex] = true;
to hide a column.
In a GridGroupingControl, you use code like:
grid.TableDescriptor.VisibleColumns.Remove("columnName");
AD
Administrator
Syncfusion Team
February 1, 2007 12:01 PM UTC
Thanks for details...
Actually i want 2 functionalities hide columns and delete columns from the grid...
User can unhide the earlier hiden column but should not get deleted column back....
How to achieve these 2 functionalities and unhide the column
AD
Administrator
Syncfusion Team
February 1, 2007 07:01 PM UTC
Hi,
Issue 1: Hide/Unhide the column:
In a GridControl or GridDataBoundGrid, A column can be hidden or unhidden by just setting the this.gridControl1.Cols.Hidden[colIndex] = true;
and this.gridControl1.Cols.Hidden[colIndex] = false; respectively.
In a GridGroupingControl, you use the VisibleColumns property of the GridTableDescriptor to show / hide the columns in the grid. Below is a code snippet
//For hide the "Col0" column
this.grid.TableDescriptor.VisibleColumns.Remove("Col0");
//For show the "Col0" column
this.grid.TableDescriptor.VisibleColumns.Add("Col0");
Issue 2: Remove the column from the grid.
In a GridControl, the column can be removed by calling the gridControl1.Model.Cols.RemoveRange(from,to);
In a GridDataBoundGrid or GridGroupingControl, column can be removed by using the underlying datasource of the grid. Here is a code.
DataTable dt = grid.DataSource as DataTable;
dt.Columns.Remove("Col1");
dt.AcceptChanges();
Best Regards,
Haneef