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

Manipulating the silverlight datagrid from code behind?

Thread ID:





94249 Apr 30,2010 08:33 PM UTC May 13,2010 10:54 AM UTC Silverlight 3
Tags: GridControl
Asked On April 30, 2010 08:33 PM UTC

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.


Varun P [Syncfusion]
Replied On 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.


Please let me know if you have any queries.


Pankaj Mittal
Replied On 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?


Varun P [Syncfusion]
Replied On 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.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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