zoukankan      html  css  js  c++  java
  • 控制DataGirdView中單元格

    this.dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing);

    void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
      {
       if (e.Control is DataGridViewComboBoxEditingControl)
       {
        if (!isRegedit)
        {
         ((DataGridViewComboBoxEditingControl)e.Control).DropDown += new EventHandler(uclMPODetailListView_DropDown);
         ((DataGridViewComboBoxEditingControl)e.Control).SelectedIndexChanged += new EventHandler(uclMPODetailListView_SelectedIndexChanged);
         ((DataGridViewComboBoxEditingControl)e.Control).KeyDown += new KeyEventHandler(uclMPODetailListView_KeyDown);
         isRegedit = true;
        }

       }
       else
       {
        isRegedit = false;
       }

       if (e.Control is ImageButtonTextBoxEditingControl)
       {
        if (dataGridView1.CurrentCell.ColumnIndex == 0)
        {
         //if (!((ImageButtonTextBoxEditingControl)e.Control).HasRegedited)
         //{
         ((ImageButtonTextBoxEditingControl)e.Control).ReSetClickEvent();
         ((ImageButtonTextBoxEditingControl)e.Control).imageButtonClicked += new EventHandler(uclMPODetailListViewMO_imageButtonClicked);
          //((ImageButtonTextBoxEditingControl)e.Control).HasRegedited = true;
         //}
        }

        if (dataGridView1.CurrentCell.ColumnIndex == 18)
        {
                        ((ImageButtonTextBoxEditingControl)e.Control).KeyPress += new KeyPressEventHandler(imageCtrl_KeyPress);
         ((ImageButtonTextBoxEditingControl)e.Control).ReSetClickEvent();
         ((ImageButtonTextBoxEditingControl)e.Control).imageButtonClicked += new EventHandler(uclMPODetailListViewPO_imageButtonClicked);
        }
       }
      }

            void imageCtrl_KeyPress(object sender, KeyPressEventArgs e)
            {
                e.Handled = true;
            }

  • 相关阅读:
    微信打开网址添加在浏览器中打开提示遮罩
    Java内存分配之堆、栈和常量池
    腾讯面试题04.进程和线程的区别?
    cookie 和 session的区别
    jvm内存模型-回收算法-和内存分配以及jdk、jre、jvm是什么关系(阿里,美团,京东面试题)
    HTTP中GET与POST的区别
    Socket send函数和recv函数详解
    JSP九大内置对象及四个作用域
    JavaScript
    网页布局(html+css基础)
  • 原文地址:https://www.cnblogs.com/springxie/p/1509542.html
Copyright © 2011-2022 走看看