就是把没有权限的列值让用户看不到,显示成******** 

解决方案 »

  1.   

    动态设置visible就可以了,什么用户看什么列,那是你来控制的
      

  2.   


    //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);
                }
            }
      

  3.   


    //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);
                }
            }
      

  4.   

    取数据时的按用户权限来少取某些列
    要是已经取了所有数据,就按权限来Filter一下,再绑定
    或者绑定后判断权限设置Visiable
      

  5.   

    在设计的时候多加一列,显示为*****,这样根据权限判断,设置对应列的visible值
      

  6.   

    根据权限获取不显示真实值的列名放到一个集合里面
    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);
                }
            }
      

  7.   

    比如原来有012345列,楼主想让没有权限的用户看不到第5列,显示成********  
    那么添加第6列,设置显示内容为********  
    程序运行时判断,如果用户有权限则第5列visible为true第6列visible为false
    如果用户无权限则第5列visible为false,第6列visible为true不知道这样说楼主明白没