473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

winforms equivalent of asp.net page load event

Hi,

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..

Jun 27 '08 #1
4 5951
"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.

Jun 27 '08 #2
On May 19, 11:30 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"parez" <psaw...@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.
Thanks.. I asked the wrong question. but i got the right answer..
Jun 27 '08 #3
On May 19, 11:30 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"parez" <psaw...@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.
There is a problem. My first event which is wired up by the designer
runs first. The first event handler displays the current message and
the second event handler(button_click) clears it. I wire up the
button_click in my base form Load Event

Is there a way around this problem? or should i look for an
alternative solution for the initial problem?
Jun 27 '08 #4
"parez" <ps*****@gmail.comwrote in message
news:1f**********************************@f63g2000 hsf.googlegroups.com...
There is a problem. My first event which is wired up by the designer
runs first. The first event handler displays the current message and
the second event handler(button_click) clears it. I wire up the
button_click in my base form Load Event

Is there a way around this problem? or should i look for an
alternative solution for the initial problem?
I don't see any elegant and simple workaround.
You could inherit from the Button class, and then in your own button
override the OnClick method. You can then choose wether to call base.OnClick
before or after you execute your own operations such as clearing the
message.
Or you could experiment using a different event for clearing the
message, such as MouseDown, or better still GotFocus, so that it also works
with the keyboard. I think that this fires before the click event, but you
will have to experiment a little bit with the available events to find the
best one.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kurt Denhoff | last post by:
I have an odbc connection on a Winforms UserControl when used within a WinForms project it works fine but when I use it on an aspx page the object doesn't show. The IIS log indicates code...
0
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind...
2
by: John Alesse | last post by:
Hi, I've created a very simple winforms control using the c# wizard in VS .net 2003 that is nothing but a System.Windows.Forms.UserControl. There are no other controls on the form It takes IE 12...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
1
by: Pieter | last post by:
Hi, In my application VB.NET 2005 application I placed a ReportViewer, and link it to a server-report: Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
18
by: Csaba Gabor | last post by:
Is there a straightforward way of implementing a PHP equivalent to window.setTimeout? In a javascript web app, it's often the case that things are done on an event driven basis. For example,...
2
by: ZBINContact | last post by:
I am creating a self-checking set of usercontrols. They tend to call their self-checking functionally in the "Load" event. I have run into a problem with my TextBox usercontrol, however, as the...
23
by: raylopez99 | last post by:
Here I am learning WinForms and two months into it I learn there's a WPF API that is coming out. Is this WPF out yet, and is it a threat to WinForms, in the sense that all the library routines I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.