0

There are many example adding event handler for other object such as button, textbox, but there are not for Windows form.

I am trying to add an event handler to my Windows form, and I stuck in error

Here is my code

            Form f = new Form();
            f.BackColor = Color.White;
            f.FormBorderStyle = FormBorderStyle.None;
            f.Bounds = Screen.PrimaryScreen.Bounds;
            f.TopMost = true;
            f.Opacity = 0.6;
            f.Click = new EventHandler(this.FakeMouseEvent);

            f.Show();

Is there anyone help me out?

I wanna use mouseClick event in dynamic form.

Badro Niaimi
  • 959
  • 1
  • 14
  • 28
user3773632
  • 445
  • 6
  • 20

1 Answers1

1

Windows Forms events are standard .NET events, so you can append your handler like

 f.Click += FakeMouseEvent;

and also remove it like

 f.Click -= FakeMouseEvent;
Thomas Hilbert
  • 3,559
  • 2
  • 13
  • 33