Reputation: 39
Can I delete the first column of a DataGridView?
Upvotes: 0
Views: 2514
Reputation: 267
To hide first column you can set RowHeadersVisible to false of your dataGrid
dataGridView1.RowHeadersVisible=false;
Upvotes: 2
Reputation: 59
There are two solutions
The first one is to delete the column from the Data Source. This one is before assigning the data source.
The second one is by hiding the column from the grid i.e.
yourGridViewName.Columns["yourColumnName"].Visibile = false;
yourGridViewName.Columns[ColumnNo].Visibile = false;
This solution is after assigning the datasource
Upvotes: 0
Reputation: 499
Yes you can hide that column
gvGridViewID.Columns[0].Visible = false;
Do this after you have gvGridViewID.DataBind();
But if the column is not required at all then you need to remove it from your datasource itself, before providing it as datasource to the gridview.
Note: Where gvGridViewID
(you might be having some other name) is the ID of the grid.
Upvotes: 0