"parez" <ps*****@gmail.comwrote in message
news:4e**********************************@27g2000h sf.googlegroups.com...
Whats the winforms equivalent of asp.net page load event?
I am trying to clear a status message field every time a user clicks
on any of the buttons..
The equivalent would be the Form_Load, but the lifecycle of the winform
is different from the webform. The Class of the webform is created and then
destroyed on every postback, so the Page_Load executes every time you press
a button that submits the form. But the Winform Class is only created once,
and it doesn't recreate every time you press a button (there is no such
thing as a postback in winforms). There is no event that will execute on
every button click except for that button's button_click itself.
If you want a trick to clear your status message on every click on any
button, you can do the following: Write a "button_click" event handler that
clears the message. Then connect that event to every button in the form. You
can do this with a recursive routine that enumerates the Controls
collection. This does not interfere with the existing button_click for each
button, since you can have both event handlers connected to the same event
at the same time.