2
Maybe the question was too comprehensive, but I wanted to know how to use the EventArgs
of certain components, such as EventArgs
in the Button_Click
.
Explaining the doubt a little better, for example. I am creating an application in which I use BackgroundWorker
and Timer
(Windows.Forms.Timer). And in the case of BackgroundWorker
when using the RunWorkerAsync
passing a parameter I can pick up the value passed in the parameter and use it in the function since the variable receives the cast
appropriate. As in the code below:
public void execBackgroundWorker()
{
BackgroundWorker bgwMain = new BackgroundWorker();
bgwMain.DoWork += BgwMain_DoWork;
int iValor = 1234;
bgwMain.RunWorkerAsync(iValor);
}
private void BgwMain_DoWork(object sender, DoWorkEventArgs e)
{
int valorParam = (int)e.Argument;
Console.Write(valorParam);
}
But in the case of a Button
, his click does not have a overload
in the PerformClick
that allows you to pass some parameter, but I still have one EventArgs
in the method call. I understand that the DoWorkEventArgs
inherits from CancelEventArgs
and CancelEventArgs
inherits from EventArgs
and that implementation ultimately allows the DoWorkEventArgs
stores the values of variables as in the code above. But what would be the functionality of EventArgs
at other events such as Click
of Button
, Tick
of Timer
, among several other events that use the generic form of EventArgs
?
What the EventArgs
stores in the Click
for it to be used?