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!");
            }
        }
  • 相关阅读:
    css 基础
    css 基础-1
    html 入门2-表
    CMDB (后台管理) CURD 插件
    序列化
    AES(高级加密)
    API验证
    数据库取时间(分组)
    用户权限 (知识点)
    xss 过滤
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10490552.html
Copyright © 2011-2022 走看看