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

  • 相关阅读:
    Vue(小案例_vue+axios仿手机app)_go实现退回上一个路由
    nyoj 635 Oh, my goddess
    nyoj 587 blockhouses
    nyoj 483 Nightmare
    nyoj 592 spiral grid
    nyoj 927 The partial sum problem
    nyoj 523 亡命逃窜
    nyoj 929 密码宝盒
    nyoj 999 师傅又被妖怪抓走了
    nyoj 293 Sticks
  • 原文地址:https://www.cnblogs.com/boneking/p/1333795.html
Copyright © 2011-2022 走看看