datagridView只读属性设置 ??????

罗汉松驻扎的工作基地 2012-08-02 10:02:51
请问在datagridView中能不能只让其中一个单元格的readonly属性为false , 而不是整个datagridView的readonly为false ??
...全文
282 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
laokaizzz 2012-08-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
代码可以的,你没有把它们放在合适触发事件当中。

引用 2 楼 的回复:

这位大侠,我这样写还是不行哦,第0个单元格还是可以编辑的 ,为什么呢??
int currRow = this.dataGridView1.CurrentCell.RowIndex;
this.dataGridView1.Rows[currRow].Cells[0].ReadOnly = true;
[/Quote]
+1
暖枫无敌 2012-08-02
  • 打赏
  • 举报
回复
要是整列只读的话,直接
dataGridView1.Columns[0].ReadOnly = true;

设置某列的某个单元格只读的话
dataGridView1[2,0].ReadOnly = true;
暖枫无敌 2012-08-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

这位大侠,我这样写还是不行哦,第0个单元格还是可以编辑的 ,为什么呢??
int currRow = this.dataGridView1.CurrentCell.RowIndex;
this.dataGridView1.Rows[currRow].Cells[0].ReadOnly = true;
[/Quote]
你是想让整列都只读还是该列中某个单元格内容只读??

xxjltan 2012-08-02
  • 打赏
  • 举报
回复
代码可以的,你没有把它们放在合适触发事件当中。
[Quote=引用 2 楼 的回复:]

这位大侠,我这样写还是不行哦,第0个单元格还是可以编辑的 ,为什么呢??
int currRow = this.dataGridView1.CurrentCell.RowIndex;
this.dataGridView1.Rows[currRow].Cells[0].ReadOnly = true;
[/Quote]
  • 打赏
  • 举报
回复
这位大侠,我这样写还是不行哦,第0个单元格还是可以编辑的 ,为什么呢??
int currRow = this.dataGridView1.CurrentCell.RowIndex;
this.dataGridView1.Rows[currRow].Cells[0].ReadOnly = true;
bdmh 2012-08-02
  • 打赏
  • 举报
回复
dataGridView1.Rows[0].Cells[0].ReadOnly

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧