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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to hide column on mouse right button click

Thread ID:

Created:

Updated:

Platform:

Replies:

55439 Jan 30,2007 01:36 PM UTC Feb 1,2007 07:01 PM UTC WinForms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 30, 2007 01:36 PM UTC

I need to hide/unhide column on mouse click on menu.

How to do?

Administrator [Syncfusion]
Replied On 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");



Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

CONFIRMATION

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.

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

;