Windows Form

Hiding a Property From Displaying in Datagridview in C#.NET

The below example demonstrates hiding a property of a class from displaying in Datagridview.  When you bind a class objec to datagridview with help of bindinglist, by default all properties will be displayed in datagridview.

Property name will be the column name of datagridview and each object values are displayed as one row.

If you want  to hide any property of class from displaying , you can use Browsable attribute which is present in System.ComponentModel namespace.

Please find the code snippet below for making property invisible in Datagridview.

Employee

When you assign above datatable to Datagridview, the data in Datagridview looks as below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.