Click here to Skip to main content
15,908,842 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
how to make a column invisible in gridview without using item template
Posted

Set the property Visible of the GridViewColumn to false.

For example

I have a column named
XML
private System.Windows.Forms.DataGridViewTextBoxColumn groupNameDataGridViewTextBoxColumn;


Then in code:
C#
//
// groupNameDataGridViewTextBoxColumn
//
this.groupNameDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.groupNameDataGridViewTextBoxColumn.DataPropertyName = "GroupName";
this.groupNameDataGridViewTextBoxColumn.HeaderText = "GroupName";
this.groupNameDataGridViewTextBoxColumn.Name = "groupNameDataGridViewTextBoxColumn";
this.groupNameDataGridViewTextBoxColumn.ReadOnly = true;
this.groupNameDataGridViewTextBoxColumn.Visible = false;
 
Share this answer
 
v2
GridView1.Columns[0].Visible=False;

Pass the index of Column
 
Share this answer
 
When you want to make it invisible , on that event you have to write

GidViewName.Column[ColumnIndex].Visible =flase;

ColumnIndex starts from 0 , in grid view.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900