NachoRuba
NachoRuba

Reputation: 39

Delete selected row column in DataGridView

Can I delete the first column of a DataGridView?

enter image description here

Upvotes: 0

Views: 2514

Answers (3)

Aliasghar Bahrami
Aliasghar Bahrami

Reputation: 267

To hide first column you can set RowHeadersVisible to false of your dataGrid

dataGridView1.RowHeadersVisible=false;

Upvotes: 2

Muhammad Nasir Khan
Muhammad Nasir Khan

Reputation: 59

There are two solutions

  1. The first one is to delete the column from the Data Source. This one is before assigning the data source.

  2. 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

Dinesh Prajapati
Dinesh Prajapati

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

Related Questions