954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Hiding DataGridview Columns runtime

How can i Hide/shows columns in datagridview runtime ?
I have a window application form with a comboBox and a grid.
As according to selection in comboBox Items, I want to hide or show
datagridview columns as according to combobox item selection

Naik Dhiren
Newbie Poster
16 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

dataGridView1.Columns["column name\ index"].Visible = true\false;

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Dear RamyMahrous
thanks for reply
i have tried the visible property. but my grid is binding grid[ i.e.datasouce] so last columns of grids has been visible false/true
but middle columns are not

so pls guide me. thanks again

Naik Dhiren
Newbie Poster
16 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

Look I tried it myself, it works
I dragged and dropped a DataGridView control, I binded it a datasource, then I dragged and dropped a Button, on its ClickEvent handler I wrote this code

dataGridView1.Columns[2].Visible = false;

It removes this column == it works.
Or I don't understand you.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You