Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding default gray column in datagridview winform

Tags:

c#

winforms

Is there any way to remove or hide winform's datagrid gray area when data is not avaiable?

Second this how to remove/hide the default gray column?

  dataGridView1.DataSource = oresult;   dataGridView1.Columns["Id"].Visible  = false;   dataGridView1.Columns["AddedBy"].Visible = false;   dataGridView1.Columns["AddmissionInClass"].Visible = false;   dataGridView1.Columns["IsDeleted"].Visible = false;   dataGridView1.Enabled = false; 

I'm hiding useless columns like this but unable to find way to hide these.

enter image description here

like image 311
DDR Avatar asked Mar 27 '13 06:03

DDR


People also ask

How to hide a column in DataGridView?

To hide a column programmaticallySet the DataGridViewColumn. Visible property to false .

How to get rid of first column in DataGridView?

DataGridView's column index starts from zero. Hence, if you want to hide first column, you can do, dataGridView1. Columns[0].

How do you make grid column visible false in GridView?

The way to hide a column in a DataBound GridView is to trap the RowCreated Event and set a Cell inside the column of the row to Visible = false.


2 Answers

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

like image 64
JleruOHeP Avatar answered Sep 18 '22 14:09

JleruOHeP


Just set the Background-Color and the RowHeadersVisible-State of your DataGridView:

dataGridView1.BackgroundColor = Color.White; dataGridView1.RowHeadersVisible = false; 
like image 26
Tomtom Avatar answered Sep 18 '22 14:09

Tomtom