读书人

如何让DataGridView 有的行有几列不可

发布时间: 2012-01-12 22:11:58 作者: rapoo

怎么让DataGridView 有的行有几列不可编辑.

例如: 显示为
-----------------------
窗体名称 执行 创建 修改 删除

数据连接 1 1 1 1

FTP 1 0 1 0

系统配制 1 不要显示窗体内容
-----------------------
各位高手,请问改怎么设置DataGridView能显示到上面的效果

执行 创建 修改 删除 的字段是Bit

[解决办法]
老兄啊,你还是没有理解呀,不能照搬的了,是要掌握这个思路。
下面的例子随便写在一个调用的函数里即可。

示例:让 "系统配置 "所在的行的3、4、5列内容不显示

foreach(DataGridViewRow myRow in this.DataGridView1.Rows)
{
if(myRow.Cells[0].Value.ToString()== "系统配置 ")
{
myRow.Cells[2].Value= " ";
myRow.Cells[3].Value= " ";
myRow.Cells[4].Value= " ";
}
}
[解决办法]
整列(第二列)不可编辑:
this-> dataGridView-> Columns[2]-> ReadOnly = true;

第i行第j列的单元格不可编辑:
this-> setParam_dataGridView-> Rows[i ]-> Cells[j]-> ReadOnly = true;

以上是vs.net c++代码

读书人网 >C#

热点推荐