mahesh waghela

mahesh waghela

  • NA
  • 93
  • 114.1k

Event Not Fired On Editing Control Of Datagridview

Nov 14 2011 12:44 PM
There is strange problem I am facing that I have custome datagridview in my application and I am trying to fire even on Editing ControlShowing Event Of datagridview as below:


        private void newdgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            TextBox tbox = e.Control as TextBox;
            if (newdgv.CurrentCell.ColumnIndex == 0) 
            {
                    
                tbox.TextChanged+=new EventHandler(tbox_TextChanged);
                tbox.KeyDown += new KeyEventHandler(tbox_KeyDown);

                
            }
        }

        private void tbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.C)
            {
                CashShortAC4 csa4 = new CashShortAC4();
                csa4.Bt_Click += new CashShortAC4.CShortAC1(csa4_Bt_Click);
                csa4.Show(this);
            }
        }

        private void tbox_TextChanged(object sender, EventArgs e)
        {
            TextBox tbox = (TextBox)sender;
            if (tbox.Text.Length > 2)
            {

                listBox2.Visible = true;
                button2.Visible = true;

                int inddex = listBox2.FindString(tbox.Text);

                if (inddex != -1)
                {
                    listBox2.SetSelected(inddex, true);
                    listBox2.Focus();
                    tbox.TextChanged -= new EventHandler(tbox_TextChanged);

                }

            }
        }
The tbox TextChanged event working very well but tbox keydown event not working. When I Press Ctrl+C on Editing Control like textbox it's not showing me the concern new form CashShortAC4.  I don't know what is wrong in my application. How to solve the problem?.
 




Answers (6)