Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide a specific column form a dataGridView?

Tags:

c#

winforms

How can I hide a specific Column in DataGridview along with its header while being able to use its value ? ( just doesn't get shown ) . The following code doesn't work.

 gridview.Rows[e.RowIndex].Cells[11].Visible = false;
like image 634
Hossein Avatar asked Feb 26 '13 13:02

Hossein


People also ask

How to hide column from GridView in vb net?

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.

What is DataGridView in C#?

The DataGridView control provides a customizable table for displaying data. The DataGridView class allows customization of cells, rows, columns, and borders through the use of properties such as DefaultCellStyle, ColumnHeadersDefaultCellStyle, CellBorderStyle, and GridColor.


2 Answers

Try this:

gridview.Columns["ColumnName"].Visible = false;

Hide Columns in the Windows Forms DataGridView Control

like image 125
Leo Chapiro Avatar answered Oct 04 '22 00:10

Leo Chapiro


This is 100% correct solution.... this.dataGridView1.Columns[0].Visible = false;

like image 45
Sohail Malik Avatar answered Oct 04 '22 00:10

Sohail Malik