D
Dom
When I create a UserControl, I inherit certain events, in particular,
the TextChanged and KeyDown events. Yet I can't seem to capture them,
and I think I know why. If my UserControl contains a TextBox and a
ListBox, which one fires the KeyDown event? or the TextChanged event?
Are these events just there for me to override, if I need to? If so,
is this the right way:
public delegate void KeyDownDelegate(object sender,
KeyEventArgs e);
public new event KeyDownDelegate KeyDown;
protected override void OnKeyDown(KeyEventArgs e)
{
if (KeyDown != null) KeyDown(this, e);
}
Notice the "new" in the second line, and the "override" in the third
line. I did this by hit or miss. Another possibility is to NOT
declare anything at all, but just call OnTextChanged and OnKeyDown as
I need them.
Which is the right way?
the TextChanged and KeyDown events. Yet I can't seem to capture them,
and I think I know why. If my UserControl contains a TextBox and a
ListBox, which one fires the KeyDown event? or the TextChanged event?
Are these events just there for me to override, if I need to? If so,
is this the right way:
public delegate void KeyDownDelegate(object sender,
KeyEventArgs e);
public new event KeyDownDelegate KeyDown;
protected override void OnKeyDown(KeyEventArgs e)
{
if (KeyDown != null) KeyDown(this, e);
}
Notice the "new" in the second line, and the "override" in the third
line. I did this by hit or miss. Another possibility is to NOT
declare anything at all, but just call OnTextChanged and OnKeyDown as
I need them.
Which is the right way?