Hello
A basic issue about events in a WindForm program in Visual Studio 2022 Enterprise
I had abandoned the dev in C#; Help me
My code:
Obviously, I am here because no event is triggered.
I can't see my mistake.
In the debugging of the app, I always find "event_momo" of type "EventHandler" but always value "= null" (so ditto for "eh").
When running the app, the compiler is silent ... But no event is launched.
What for???? Thank you for your help.
In this rather simple app, all events related to controls (like click on button ...) work wonderfully ....
Molo
A basic issue about events in a WindForm program in Visual Studio 2022 Enterprise
I had abandoned the dev in C#; Help me
My code:
First class:
public partial class Form2 : Form
{
public EventHandler event_momo; // déclaration de l'évènement
// déjà ici, dans debogage, "event_momo = null" mais de type EventHandler ????
//....
// plus loin, dans la méthode qui va déclencher l'évènement
EventHandler eh = event_momo;
if ( eh != null )
{
eh.Invoke(this, EventArgs.Empty);
}
//....
}
Second class:
public partial class Form1 : Form
{
// pour abonner une méthode à l'évènement
Form2 f2 = new Form2();
f2.event_momo += Maj_fichier;
//....
}
Obviously, I am here because no event is triggered.
I can't see my mistake.
In the debugging of the app, I always find "event_momo" of type "EventHandler" but always value "= null" (so ditto for "eh").
When running the app, the compiler is silent ... But no event is launched.
What for???? Thank you for your help.
In this rather simple app, all events related to controls (like click on button ...) work wonderfully ....
Molo
Last edited by a moderator: