Click here to Skip to main content
15,885,111 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello,

iam using datagridview1 having 5 columns like column1,column2,column3.....column5
if iam using check box clicked show all 5 columns else only column1 showing.
plz help me the code
Posted

Under check box checked event

Gridview1.Columns[5].Visible=false;
else
bind_gridview();
 
Share this answer
 
Comments
Member 10570811 22-Sep-14 8:01am    
showing compiler error bind_gridView()
Dirty but worky

Iterate through the datagridview columns and set them to Visible = false or Visible = true.
You have to do this in the checkBox_checkstatechanged event

C#
for(int i = 0; i < datagridview1.columns.count; i++)
{
    if(checkbox.checked)
    {
        datagridview1.columns[i].visible = true;
    }
    else if(...etcetc...
}


Edit: Typo and Line 5
 
Share this answer
 
v2
Comments
Member 10570811 23-Sep-14 3:31am    
this is perfect but i actually i want like ref given link
https://www.mediafire.com/?epa08n11192badf
or
http://www.mediafire.com/view/epa08n11192badf/show_and_hide.jpg
Member 10570811 23-Sep-14 7:17am    
i done my self
HobbyProggy 23-Sep-14 8:37am    
okay :)
I am at work and had no chance to check that out till yet

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