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

Manipulating the silverlight datagrid from code behind?

Hi
I am building a usercontrol which will contain Syncfusion silverlight datagrid. And I want to control visibility of columns from code behind. Are there any links to such samples?

In fact, I would like to know how to control other controls from code behind.

Thanks
AJ

3 Replies

VP Varun P Syncfusion Team May 3, 2010 09:13 AM UTC

Hi Pankaj,

Thanks for using Syncfusion products.

To control the VisibleColumns in code behind, set the AutoPopulateColumns="False" in the xaml.

In the code behind file use the following code to make the columns to be visible.

this.dataGrid.VisibleColumns.Add(new Syncfusion.Windows.Controls.Grid.GridDataVisibleColumn() { MappingName="OrderID",HeaderText="OrderID"});

I have attached a sample in the below location.

VisibleColumnSample-1669147914.zip

Please let me know if you have any queries.

Thanks,
Varun


PM Pankaj Mittal May 7, 2010 03:34 PM UTC

Thanks. but how to hide a column even though it is part of grid columns?

Also, how can we enable the click handler of a cell in grid?

Thanks


VP Varun P Syncfusion Team May 13, 2010 10:54 AM UTC

Hi Pankaj,

You can set the width of the column to 0 and it will not be shown in the grid. Please refer the below code snippet.







You can handle the cell click event. Please look into the below code snippet.

this.dataGrid.Model.Grid.CellClick += new GridCellClickEventHandler(Grid_CellClick);

Please let me know if you have any queries.

Thanks,
Varun

Loader.
Live Chat Icon For mobile
Up arrow icon