datagrid view coloumn show and hide [英] datagrid view coloumn show and hide

查看:103
本文介绍了datagrid view coloumn show and hide的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



iam使用datagridview1有5列,如column1,column2,column3 ..... column5

if iam using复选框单击显示所有5列,否则只显示column1。

plz帮我代码

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

推荐答案

复选框下选中的事件



Gridview1.Columns [5] .Visible = false;

else

bind_gridview();
Under check box checked event

Gridview1.Columns[5].Visible=false;
else
bind_gridview();


脏但工作很好



通过datagridview列迭代并将它们设置为Visible = false或Visible = true。

您必须在checkBox_checkstatechanged事件中执行此操作



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

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





编辑:错字和第5行



Typo and Line 5


这篇关于datagrid view coloumn show and hide的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆