Hiding default gray column in datagridview winform
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.
To hide first column you can set RowHeadersVisible
to false of your dataGrid
Just set the Background-Color and the RowHeadersVisible-State of your DataGridView:
dataGridView1.BackgroundColor = Color.White;
dataGridView1.RowHeadersVisible = false;
You need set properties for RowHeaderVisible (from gridview properties) to be false
Just put this piece of code. Worked for me.
DataGrid.RowHeadersVisible = false;
DataGrid.ColumnHeadersVisible = false;
You have two approaches to do this:
-
Adding this line:
dataGridView1.RowHeadersVisible = false;
to...
private void Form1_Load(object sender, EventArgs e) { dataGridView1.RowHeadersVisible = false; }
-OR-
From (Project's Properties) window change True to false like this: