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. Image for the cookie policy date
close icon

GridDataBoundGrid control

I have a griddataboundgrid control and an attached datasource
I do not want to display every column of the corresponding DataMember (a Datatable object)
How could I define the collection of columns I would like to be displayed?

GroupingGridControl has a TableDescriptor.VisibleColumns collection to do this.

There is any similar for GridDataBoundGrid ?

1 Reply

AD Administrator Syncfusion Team March 6, 2007 02:48 AM UTC

Hi Matyas,

To rearrange columns in grid, you can use the Binder.LayoutColumns(). This method rearranges how the columns should be displayed in the grid.
Please try the code below after the binding the datasource to the grid. This will rearrange the columns as desired.

this.gridDataBoundGrid1.Binder.LayoutColumns(new string[] {"Col2", "Col5", "Col3", "Col1", "Col4"});


--OR---

You can also move columns in the DataBoundGrid, using the grid.Model.Cols.MoveRange method.
See the code below,

// moves column 1 to 3
this.gridDataBoundGrid1.Model.Cols.MoveRange(1, 3);

//moves column 1 & 2 to 4
this.gridDataBoundGrid1.Model.Cols.MoveRange(1,2,4);


Here is a sample demonstrating this. MoveColumns.zip

If you dont want certain columns to displayed, then you can hide them as in the code below.

this.gridDataBoundGrid1.Model.HideCols["colName"] = true;
//or
this.gridDataBoundGrid1.Model.HideCols[colindex] = true;

Thankyou,
S.Shyam.

Loader.
Live Chat Icon For mobile
Up arrow icon