解决方案 »

  1.   

    DataGridView我也研究了一段时间, 我觉得你的问题就是那个地方把数据给改了。
    如果方便的话, 可以把你的代码贴出来。
      

  2.   

    你可以在DataGridView的触发事件中看看这两个函数。cellvalidating  and cellvalidated
      

  3.   

    DataGridView数据更新事件的编写示例
    //更新数据事件
     public void Update(Instance it)
            {
                SqlConnection sc = GetConnection();//调用GetConnections()方法,得到连接对象
                try
                {
                    sc.Open();//打开到数据库的连接
                    SqlCommand cmd = new SqlCommand(//创建SqlCommand对象
                        "update tb_friend set phone=@phone where names=@names", sc);
                    cmd.Parameters.Add("@names", SqlDbType.VarChar).Value = it.Name;//向SqlCommand对象添加参数
                    cmd.Parameters.Add("phone", SqlDbType.VarChar).Value = it.phone;//向SqlCommand对象添加参数
                    cmd.ExecuteNonQuery();//执行SqlCommand对象中的SQL命令
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    if (sc.State == ConnectionState.Open)//判断是否连接数据库
                    {
                        sc.Close();//如果已经连接则关闭连接
                    }
                }
            }//codego.net/tags/1/1/
    //绑定dataGridView控件实现更新事件按钮
    private void btn_update_Click(object sender, EventArgs e)
            {
                //调用datatier对象的Update()方法,更改数据库中的信息
                dt.Update(new Instance() { Name = txt_name_update.Text, phone = txt_phone_update.Text });
                dataGridView1.DataSource = dt.Select();//更新dataGridView1控件中的信息
                Clear();//清空TextBox控件中的文本
            }
      

  4.   

    大侠,我的代码如下:
     private void dataGridView_CurveDivide_CellEndEdit(object sender, DataGridViewCellEventArgs e)
            {
                int rowIndex = dataGridView_CurveDivide.CurrentCell.RowIndex;
                int columnIndex = dataGridView_CurveDivide.CurrentCell.ColumnIndex;
                change = Convert.ToDouble(dataGridView_CurveDivide.CurrentCell.Value);
                CalculateNewValue(change,rowindex,columnindex);//根据新输入的值重新计算数组中的值
                ImportDataToDatagridview();//把数组中的数据导入到datagridview中
     
            }
    我把  ImportDataToDatagridview()写入到两个验证函数里没有用哎???