zoukankan      html  css  js  c++  java
  • [C#]给DataGridView里的ComboBoxCol添加SelectIndexChange事件

            const string DGVCBCellType = "System.Windows.Forms.DataGridViewComboBoxCell";
            const string DGVTBCellType = "System.Windows.Forms.DataGridViewTextBoxCell";

           public CDynIngDGV()  //构造函数
            {
                this.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(CDynIngDGV_EditingControlShowing);
                this.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
            }

            void CDynIngDGV_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
            {

                switch (e.Control.GetType().ToString())
                {
                    case DGVCBCellType:
                        ((ComboBox)e.Control).SelectedValueChanged += new EventHandler(CDynIngDGV_SelectedValueChanged);
                        break;

                    case DGVTBCellType:

                        break;
                }
               
            }

            void CDynIngDGV_SelectedValueChanged(object sender, EventArgs e)
            {
                switch (sender.GetType().ToString())
                {
                    case DGVCBCellType:
                        MessageBox.Show(((ComboBox)sender).SelectedValue.ToString());
                        break;

                    case DGVTBCellType:

                        break;
                }
               
            }

  • 相关阅读:
    DES加密和解密PHP,Java,ObjectC统一的方法
    TreeSaver 使用教程整理——Step 3: Creating Grids
    android面试题目汇总持续更新
    Android SQLiteHelper
    Android计算地图上两点距离
    asp.net 下载文件几种方式
    android 权限
    ORA01795的原因及解决办法
    C# winFrom 通过注册新协议实现网页链接打开本地程序
    Android 读SIM卡信息
  • 原文地址:https://www.cnblogs.com/boneking/p/1333795.html
Copyright © 2011-2022 走看看