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;
                }
               
            }

  • 相关阅读:
    《炒股的智慧》
    python函数初识
    python文件操作
    python 表 字典 数据补充
    python深浅copy,is,id
    python列表字典小练习
    python列表字典练习
    python for/range练习
    python列表练习
    python每日小练习
  • 原文地址:https://www.cnblogs.com/boneking/p/1333795.html
Copyright © 2011-2022 走看看