.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Hide column/columns from silverlight/wpf datagrid...

Posted By:Subhransu Sekhar Jena       Posted Date: November 18, 2014    Points: 40    Category: Collections    URL: http://www.dotnetspark.com  

Dynamically hide or unhide datagrid columns in silverlight.

If you want to hide datagrid columns in silverlight then follow these steps (Code Behind):

In VB:

dgSample.Columns(0).Visibility = Visibility.Collapsed

Note: Rename dgSample to your datagrid name.
In C#:

dgSample.Columns[0].Visibility = Visibility.Hidden;

Note: Rename dgSample to your datagrid name.

The above code will hide the specific column of datagrid.
Note: Change the index position of that column which you want to hide.

If you want to hide based on data bind then you can do like below
                <DataGridTextColumn Width="100" Header="ID" Binding="{Binding _ID}"></DataGridTextColumn>
                <DataGridTextColumn Width="100" Header="Name" Binding="{Binding _Name}"></DataGridTextColumn>
                <DataGridTextColumn Width="100" Header ="City" Visibility="{Binding _ValidCity}" Binding="{Binding _ValidCity}"></DataGridTextColumn>


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend