Hi , I have created a customcontrol textbox as below
public partial class customtextbox : TextBox
{
// private Caret caret;
public customtextbox()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Down)
{
SendKeys.Send("{TAB}");
//disable beep
e.Handled = e.SuppressKeyPress = true;
}
if ((e.KeyCode == Keys.Back || e.KeyCode == Keys.Up) && this.Text.Length == 0)
{
SendKeys.Send("+{TAB}");
}
}
// form2.cs
public partial class Form2 : Form
{
private DataSet dataSet;
public Form2()
{
InitializeComponent();
}
private void customtextbox3_KeyDown(object sender, KeyEventArgs e)
{
//code for results up and down in popup datagridview
if (dataGridView1.CurrentCell == null)
{
return;
}
else
{
int rpos = dataGridView1.CurrentCell.RowIndex;
int cpos = dataGridView1.CurrentCell.ColumnIndex;
switch (e.KeyCode)
{
case Keys.Up:
rpos--;
if (rpos >= 0) dataGridView1.CurrentCell = dataGridView1.Rows[rpos].Cells[cpos];
e.Handled = true;
break;
case Keys.Down:
//int rpos1 = dgvUserTypes.CurrentCell.RowIndex;
//int cpos1 = dgvUserTypes.CurrentCell.ColumnIndex;
rpos++;
if (rpos < dataGridView1.Rows.Count) dataGridView1.CurrentCell = dataGridView1.Rows[rpos].Cells[cpos];
e.Handled = true;
break;
}
}
}
now i have used several of these textboxes in my form2 . the problem is for a particular customtextbox on this form2.cs , i don't want the base class's OnKeyDown implementation to be called as in my form2.cs , as i have used to same functionality along with some extra checks for this particular customtextbox . and at the same time i found out that the just after customtextbox3_KeyDown is called , the OnKeyDown is also called which disturbs the execution flow of my program . Please suggest me a way