Reputation: 123
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.
Upvotes: 6
Views: 14689
Reputation: 99
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.
Upvotes: 1
Reputation: 1959
Select the datagridview and open property, there in property list you can set it to false like mentioned in 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;
Upvotes: 4
Reputation: 18182
For C# Winforms,
dataGridView1.ColumnHeadersVisible = false;
For asp.net (reader looking for a web solution)
dataGridView1.ShowHeader = false;
Upvotes: 1
Reputation: 870
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;
Upvotes: 7