本文介绍了如何通过复选框列表控件使用C#.net(Winform)在Datagridview中隐藏和显示列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道怎么办?请帮帮我..



Ex:





请参阅此链接 []





在此链接中,右键单击事件显示上下文菜单,但我想在复选框中显示该列选择没有右键单击的列表



Ex: []



i need2nd link方法

i have no idea ho to do?please help me..

For Ex:


see this link A DataGridView Column Show/Hide Popup[^]


In this link the context menu appeared by rightclick event, But i want to show that column selection in checkbox list without rightclick

Ex:http://www.dotnetspark.com/kb/1875-show-hide-datagrid-columns-wpf.aspx[^]

i need2nd link method

推荐答案

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{   
    e.Row.Cells[index].Visible = checkedColumnsList.Contains(index)? true : false; 
}





请注意,每次用户检查或取消选中可见性时,您必须再次绑定gridview以触发再次使用GridView_RowDataBound事件,从而改变可见性。



Note that every time user checks or unchecks the visibility you have to Bind the gridview again in order to trigger the GridView_RowDataBound event again and thus change the visibility.


这篇关于如何通过复选框列表控件使用C#.net(Winform)在Datagridview中隐藏和显示列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:19