这是我的代码片段,给DataGridView的某个单元格赋值,紧接着弹出此单元格的值,可每次弹出的值却是"0"。this.DGVDevice["SaveFlg", e.RowIndex].Value = "1";
MessageBox.Show(this.DGVDevice["SaveFlg", e.RowIndex].Value.ToString());奇怪不?你说奇怪不!

解决方案 »

  1.   

    最好贴出所有代码,这两句别人怎么分析啊?这是我的代码,可以正常弹出:        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                try
                {
                    if(this.dataGridView1 != null)
                    {
                        this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value =
                              e.RowIndex.ToString() + e.ColumnIndex.ToString();                    MessageBox.Show(this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
      

  2.   

    dataGridView1[1, 0].Value = "hello";
    MessageBox.Show(dataGridView1[1, 0].Value.ToString());
    测试是可以的,是不是LZ第一句设置出错了(未设置成功),第二句取到的是原先的值?