zoukankan      html  css  js  c++  java
  • 检查DataGridView中的值是否修改

    We can register the events "CellBeginEdit", "CellValidating" and "CellEndEdit" at the same time to get the two values before and after the modification and compare them.

        string begin = "";
        string end = "";
    
        private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (dataGridView1.CurrentCell.Value == null)
            {
                begin = "";
            }
            else
            {
                begin = dataGridView1.CurrentCell.Value.ToString();
            }
        }
    
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            end = e.FormattedValue.ToString();
        }
    
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (begin != end)
            {
                MessageBox.Show("Value Changed!");
            }
        }
  • 相关阅读:
    7
    6
    5.1
    5
    C#类库帮助类
    Asp.net 数据库依赖那些事
    C#使用NLog记录日志
    JQuery常用操作实现方式
    常用Sql 标量值函数
    Sql语句查询XML
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10490552.html
Copyright © 2011-2022 走看看