Override event handler in windows forms [duplicate]
Hi I'm developing a windows form application with c# and I want to know if it's possible in a method of the event click have 3 parameters something like this
private void cedulaTextBox_OnClic开发者_如何学运维k(object sender, EventArgs e, KeyEventArgs ke)
Or all the time we need to declare our methods like this
private void nombreTextBox_TextChanged(object sender, EventArgs e)
thanks for your help
No. EventHandler<T>
only has options for sender and one EventArgs
. If you are writing your own event, why not roll your own EventArgs
?
Your event handler needs to match the event it is handling. If you want to have one event handler that deals with multiple different types of events, just do a little refactoring...
private void cedulaTextBox_OnClick(object sender, EventArgs e)
{
sharedHandler( sender, null, e );
}
private void nombreTextBox_TextChanged(object sender, EventArgs e)
{
sharedHander( sender, e, null );
}
private void sharedHandler( object sender, EventArgs textChangedArgs, EventArgs clickedArgs )
{
...
}
精彩评论