Click here to Skip to main content
15,903,750 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
How can we hide coloums at run time in datagridview?
Posted

VB
DataGridView1.Columns(2).Visible = False
'
'or 
'
DataGridView1.Columns("ColumnName").Visible = False
 
Share this answer
 
Comments
Vikas_Shukla_89 24-Oct-11 5:11am    
+5 frm my side
C#
for (int i = 0; i < dataGridView1.ColumnCount; i++)
{
     if (i == 0)
     {
           //set to Visible 
           dataGridView1.Columns[i].Visible = true;
     }
     else
     {
           dataGridView1.Columns[i].Visible = false;
     }
 
}
 
Share this answer
 
Try this
if (grdView.Rows.Count > 0)
{
grdView.Columns[2].Visible = false;
}
 
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