日期:2014-05-20  浏览次数:20769 次

C# winform的简单问题,在线等
我在DataGridView里添加一个DataGridViewButtonColumn
把text属性设置成 "开启 "
我想在点击按钮后把text设置成 "关闭 "
用cells[i].value属性只对文本框有效,对我要的操作无效
我刚接触winform,请高手指点一下

------解决方案--------------------
对按钮列也是可以的吧,我是在WinForm程序里测试的:
this.dataGridView1[2, 0].Value = "关闭 ";

我这里就可以的.

------解决方案--------------------
//处理CellContentClick事件

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewButtonCell vCell =
(DataGridViewButtonCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (vCell.Value == "关闭 ")
vCell.Value = "打开 ";
else vCell.Value = "关闭 ";
}
------解决方案--------------------
TO:对textbox列有效

我用的是net 2.0,你试试看行不,我这里就是不行

我测试直接可以对Text进行更改的..

for example:
this.dataGridView1.Rows[0].Cells[3].Value = "test ";

为什么你的不行呢?不妨把你写的代码贴出来看看...