Friday, 20 March 2015

How to hide the header and first empty column in datagridview using c#

Here we are going to see how to hide the header of a "DATAGRIDVIEW" in a form. First when we bind a datagridivew its like this, with a header with the database column name.




Now we want to hide the header means use the following lines
For example the Id of datagridview is dataGridView1 then
//To hide the column header
dataGridView1.ColumnHeadersVisible = false;

Then the datagridview is look like this



Now we are going to hide the first empty column from the "DATAGRIDVIEW" in the form. For this we want to the use

 //hide first empty column in gridview
 dataGridView1.RowHeadersVisible = false;



Finally the datagridview is look like this

Thanks MSDN

No comments:

Post a Comment