Maybe the question was very comprehensive, but I wanted to know how to use EventArgs
of some components, such as EventArgs
and Button_Click
.
Explaining the question a little better, for example. I'm creating an application in which I use BackgroundWorker
and Timer
(Windows.Forms.Timer). And in the case of BackgroundWorker
when I use RunWorkerAsync
passing a parameter I can get 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 Button
, its click does not have a overload
in PerformClick
that allows you to pass some parameter, but I still have EventArgs
in the method call. I understand that DoWorkEventArgs
inherits from CancelEventArgs
and CancelEventArgs
inherits from EventArgs
and that the implementation ends up allowing DoWorkEventArgs
to store variable values as in the above code. But what would be the functionality of EventArgs
in other events such as Click
Button
, Tick
Timer
, among several other events that use the generic form of EventArgs
?
What does EventArgs
store in Click
for it to be used?