How to Hide any or all column header in DataGridView?

10,126

Solution 1

While Using C# you can write the following

this.dataGridView1.Columns["CustomerID"].Visible = false;

and to Hide all the column headings you can use:

dataGridView1.ColumnHeadersVisible = false;

Solution 2

Select the datagridview and open property, there in property list you can set it to false like mentioned in screenshot .

ScreenShot

In your filename.cs file you can add something like this..

dataGridView1.ColumnHeadersVisible = false;

in your filename.Designer.cs file you will have ..

this.dataGridView1.ColumnHeadersVisible = false;

Solution 3

For C# Winforms,

dataGridView1.ColumnHeadersVisible = false;

For asp.net (reader looking for a web solution)

dataGridView1.ShowHeader = false;

Solution 4

Hide all the column headers

dataGridView.ColumnHeadersVisible = false;

Hide specific column header

dataGridView.Columns[4].Name = "Delete"; //Add name you want
dataGridView.Columns[4].HeaderText = "";

I added a column name and then I put column header text as empty. But I able to work with column name if it is not visible. This is works for me.

Share:
10,126
eddylepatio
Author by

eddylepatio

Updated on June 14, 2022

Comments

  • eddylepatio
    eddylepatio almost 2 years

    I am currently working on a Windows App using C#. I have this datagridview whose first image columns are Edit and Delete. I have an issue with hiding both their headers. How can I do that, yet keep the headers of the following columns visible?

    Thanks in advance.