设置Datagridview的总个列的视觉值为*****真实值隐藏掉 就是把没有权限的列值让用户看不到,显示成******** 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 动态设置visible就可以了,什么用户看什么列,那是你来控制的 //DataGridView CellFormatting 事件 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex==0 && e.Value!=null && e.Value.ToString().Length>0 ) { e.Value = new string('*',e.Value.ToString().Length); } } //DataGridView CellFormatting 事件 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (this.dataGridView1.Columns[e.ColumnIndex].Name=="要显示为*的列名" && e.Value!=null && e.Value.ToString().Length>0 ) { e.Value = new string('*',e.Value.ToString().Length); } } 取数据时的按用户权限来少取某些列要是已经取了所有数据,就按权限来Filter一下,再绑定或者绑定后判断权限设置Visiable 在设计的时候多加一列,显示为*****,这样根据权限判断,设置对应列的visible值 根据权限获取不显示真实值的列名放到一个集合里面private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (this.dataGridView1.Columns[e.ColumnIndex].Name=="要显示为*的列名" && e.Value!=null && e.Value.ToString().Length>0 && 该列在上面获取的集合里面) { e.Value = new string('********',e.Value.ToString().Length); } } 比如原来有012345列,楼主想让没有权限的用户看不到第5列,显示成******** 那么添加第6列,设置显示内容为******** 程序运行时判断,如果用户有权限则第5列visible为true第6列visible为false如果用户无权限则第5列visible为false,第6列visible为true不知道这样说楼主明白没 小弟为新手,各位高手给点学习C#的资源 C#异步更新界面疑难求助 vs2008 Release 问题 数据读取的“灵异”事件 c# windows服务 关于迭代器 一个简单问题,如何把一个值写到request中? 我如何判断一个窗口是否打开,如打开了就激活,类似于QQ sqlserver的问题 大家帮忙看看 高手帮忙??? DevExpress的GirdControl 的Cardcontrol的卡片排列的问题 DataGridview的删行问题
//DataGridView CellFormatting 事件
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex==0 && e.Value!=null && e.Value.ToString().Length>0 )
{
e.Value = new string('*',e.Value.ToString().Length);
}
}
//DataGridView CellFormatting 事件
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name=="要显示为*的列名" && e.Value!=null && e.Value.ToString().Length>0 )
{
e.Value = new string('*',e.Value.ToString().Length);
}
}
要是已经取了所有数据,就按权限来Filter一下,再绑定
或者绑定后判断权限设置Visiable
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name=="要显示为*的列名" && e.Value!=null && e.Value.ToString().Length>0 && 该列在上面获取的集合里面)
{
e.Value = new string('********',e.Value.ToString().Length);
}
}
那么添加第6列,设置显示内容为********
程序运行时判断,如果用户有权限则第5列visible为true第6列visible为false
如果用户无权限则第5列visible为false,第6列visible为true不知道这样说楼主明白没