I have a static event in a DLL that I use frequently – Toolkit.Dialogs.ExitConfirm
The only way I can use this event is by modifying the line that adds the event in form.Designer.cs. Example:
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
becomes
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(Toolkit.Dialogs.ExitConfirm);
If I try to add it via the Properties->Events page, it gives me this error: ‘Toolkit.Dialogs.ExitConfirm’ is not a valid identifier.
Is there a way to allow Form Designer to reference events from other classes/namespaces?
Edit: some people work better with visual cues, so here’s some images to define the issue: https://i.stack.imgur.com/3fsRd.jpg
The first image shows how I have to make it work in Visual Studio – an event that calls an event.
The second image shows what I’m actually trying to do.
The third image is the error that occurs when I key in the method name by hand.
The WinForms designer isn’t designed to do that. I’m a little surprised it doesn’t lose your event the next time you make a change in the designer.
A few ideas on other ways you could make this work:
Show).The base class is probably the simplest solution, as long as you aren’t already using form inheritance for some other purpose.