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

  • 相关阅读:
    面向对象的设计原则
    在VC中Debug下是运行结果正确的,但是在Release下却有错,总算找到原因
    聚合和组合
    痛苦呀,代码
    MSDN和VS98
    阅读代码的难度
    好香,方便面
    人的重要性
    FIT For .NET(1)
    ASP.NET Microsoft .NET Pet Shop 3.x(二)
  • 原文地址:https://www.cnblogs.com/springxie/p/1509542.html
Copyright © 2011-2022 走看看