zoukankan      html  css  js  c++  java
  • 2015.1.10 解决DataGridView SelectionChanged事件自动触发问题

    DataGridView SelectionChanged事件总是在数据源更改时自动触发,这点很讨厌。

    可以在DataBindingComplete时,再添加事件 dv8.SelectionChanged += new System.EventHandler(this.dv8_SelectionChanged);

    或用CellClick和KeyUp事件和一个函数替代SelectionChanged事件

    private void dvpt_CellClick(object sender, DataGridViewCellEventArgs e)

    {

         if (e.RowIndex < 0) return;//如果不是单击列表头

         MySelectionChanged();

    }

    private void dvpt_KeyUp(object sender, KeyEventArgs e)

    {

        if (e.KeyData == Keys.Down || e.KeyData == Keys.Up)

        {

          MySelectionChanged();

        }

    }

    public void MySelectionChanged()

    {

         if (dvpt.SelectedRows.Count == 0) return;

    ....................................................................................

    }

  • 相关阅读:
    抽象工厂
    组合和继承
    Mysql 设置远程连接
    websocket
    redis 持久化
    django urls
    git gitignore
    Mysql 系统表
    cudnn升级之后caffe无法训练的问题
    python numpy初始化一个图像矩阵
  • 原文地址:https://www.cnblogs.com/mol1995/p/5964812.html
Copyright © 2011-2022 走看看