473,386 Members | 1,786 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,386 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 5954
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.