有关dataGridView的单元格的编辑问题 先选择datagridview中的某行的任意单元格,然后点击修改按钮,此单元格处于编辑状态,然后再点击此行的其他单元格,此行的这些单元格都能够编辑,但是其他行的单元格不能为编辑请问如何实现??请给出代码,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private int iRow = -1;dataGridView1.ReadOnly = false; 设置RowEnter事件private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { dataGridView1.ReadOnly = iRow != e.RowIndex; }点击修改按钮后iRow = this.dataGridView1.SelectedRows[0].Index; 1、添加成员变量: private int iRow=-1;2、设置dataGridView1的readonly属性为true;3.private void button1_Click(object sender, EventArgs e) { this.dataGridView1.ReadOnly = false; iRow = this.dataGridView1.CurrentRow.Index; } private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (iRow != this.dataGridView1.CurrentRow.Index) { this.dataGridView1.ReadOnly = true; } else { this.dataGridView1.ReadOnly = false; } } 如何清除GDI+画的图······ 是基督徒的弟兄姊妹请进 刚学C#,做B/S模式程序是建立web站点还是web应用程序的项目啊? C# 通过.ini或.txt文件连接sql server 用C# 下载的 swf文件不完整,大家帮一下忙啊,查不出什么原因。 新手 hook的学习 如何获取系统数据源 grid翻页方式问题 新安装。net2003,创建web程序出错。。 帮忙看一下这段代码,WINCE下开发 20分求一个简单的计数问题。 在程序中调用SQL 语句进行SQL Server数据库备份,怎样判断数据库备份执行完成??
dataGridView1.ReadOnly = false;
设置RowEnter事件
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.ReadOnly = iRow != e.RowIndex;
}
点击修改按钮后
iRow = this.dataGridView1.SelectedRows[0].Index;
private int iRow=-1;
2、设置dataGridView1的readonly属性为true;
3.private void button1_Click(object sender, EventArgs e)
{
this.dataGridView1.ReadOnly = false;
iRow = this.dataGridView1.CurrentRow.Index;
} private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (iRow != this.dataGridView1.CurrentRow.Index)
{
this.dataGridView1.ReadOnly = true;
}
else
{
this.dataGridView1.ReadOnly = false;
} }