I'm trying to use a base class form to provide a simple function to all the forms in my project.
I want to be able to set the KeyPress event of any text boxes on the forms derived from my BaseForm
to be able to call that function something like this:
When I try to use the designer to assign the txtBox_KeyDown method it won't allow me, it says it's
defined already in the base class, if I manually edit the derived forms InitializeComponent to look like this:
I can compile and run the project, no errors shown, and it works as expected (allowing Enter to move to next box)
but I then get C# 'panic mode' when I later try and edit the form.
What am I missing?
Regards
Griff
Keep [Smile]ing
There are 10 kinds of people in the world, those who understand binary and those who don't.
I want to be able to set the KeyPress event of any text boxes on the forms derived from my BaseForm
to be able to call that function something like this:
Code:
public partial class BaseForm : Form
{
public BaseForm()
{
InitializeComponent();
}
public void txtBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
e.SuppressKeyPress = true;
SelectNextControl(ActiveControl, true, true, true, true);
}
}
}
When I try to use the designer to assign the txtBox_KeyDown method it won't allow me, it says it's
defined already in the base class, if I manually edit the derived forms InitializeComponent to look like this:
Code:
this.mtxtWorkScope.KeyDown += new System.Windows.Forms.KeyEventHandler(base.txtBox_KeyDown);
I can compile and run the project, no errors shown, and it works as expected (allowing Enter to move to next box)
but I then get C# 'panic mode' when I later try and edit the form.
What am I missing?
Regards
Griff
Keep [Smile]ing
There are 10 kinds of people in the world, those who understand binary and those who don't.