Hidden form and button PerformClick

  • Thread starter Thread starter stevenhaochen
  • Start date Start date
S

stevenhaochen

Form.Visible=False
Button1.PerformClick

It does not fire the Button1.Click event.
Why?
 
Don't know. But why not just call the procedure that handles the click
directly?

i.e.

<pseudocode>

Form.Visible = False
Button1_Click(me, eventargs.empty)

</pseodocode>

Thanks,

Seth Rowe
 
Seth,
Don't know. But why not just call the procedure that handles the click
directly?
One of the biggest reasons I don't call & don't recommend calling the
procedure directly is that there may be multiple handlers for the event.

By calling the handlers directly you are coupling that code to the handlers
themselves. By calling PerformClick you are only coupled to the button
itself. The number of handlers is immaterial...
 
Back
Top