473,383 Members | 1,918 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,383 software developers and data experts.

equivalent to "Load" event for a textbox.

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 base component
does NOT have a Load event as far as i can ascertain.

What I need is to have a self-check function called when the component
loads. I am currently using the "Layout" event but that can fire
multiple times, and I can't just call the method from the constructor
for multiple reasons.

So in summary:

1. Is there an event that I just haven't noticed that can be used in
place of "Load" for a TextBox
OR, lacking that
2. Is there a way to add an event or mimic this Load event behavior?
OR
3. Is there a way to fully disable the Layout event handler inside
its own code so that is guaranteed only to fire once at the beginning
of runtime and not twice nor ever again?

Whoever answers this, thank you so much for your time. This has
driven me crazy.

Nov 14 '07 #1
2 2697
Well, you might want to detail why calling the method from the
constructor isn't feasible, because this is really the way I would do it.

However, if you absolutely positively MUST not place the code in the
constructor, then you might want to place the code in the HandleCreated
event. It will be called after the handle for the window is created.

Mind you, that event can be called multiple times, so you might want to
put a flag in the event handler indicating to only run that code once, but
generally, it will be called when you show the control for the first time,
as well as when the control handle is recreated (which probably is not
often, but the point here is that it definitely is called after the
constructor, and when the first time the control is shown).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ZB*********@gmail.comwrote in message
news:11**********************@v65g2000hsc.googlegr oups.com...
>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 base component
does NOT have a Load event as far as i can ascertain.

What I need is to have a self-check function called when the component
loads. I am currently using the "Layout" event but that can fire
multiple times, and I can't just call the method from the constructor
for multiple reasons.

So in summary:

1. Is there an event that I just haven't noticed that can be used in
place of "Load" for a TextBox
OR, lacking that
2. Is there a way to add an event or mimic this Load event behavior?
OR
3. Is there a way to fully disable the Layout event handler inside
its own code so that is guaranteed only to fire once at the beginning
of runtime and not twice nor ever again?

Whoever answers this, thank you so much for your time. This has
driven me crazy.

Nov 14 '07 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:uW**************@TK2MSFTNGP06.phx.gbl...
Well, you might want to detail why calling the method from the
constructor isn't feasible, because this is really the way I would do it.

However, if you absolutely positively MUST not place the code in the
constructor, then you might want to place the code in the HandleCreated
event. It will be called after the handle for the window is created.

Mind you, that event can be called multiple times, so you might want to
put a flag in the event handler indicating to only run that code once, but
generally, it will be called when you show the control for the first time,
as well as when the control handle is recreated (which probably is not
often, but the point here is that it definitely is called after the
constructor, and when the first time the control is shown).
A teeny bit more efficient: unsubscribe from the event instead of using a
flag.
>

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ZB*********@gmail.comwrote in message
news:11**********************@v65g2000hsc.googlegr oups.com...
>>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 base component
does NOT have a Load event as far as i can ascertain.

What I need is to have a self-check function called when the component
loads. I am currently using the "Layout" event but that can fire
multiple times, and I can't just call the method from the constructor
for multiple reasons.

So in summary:

1. Is there an event that I just haven't noticed that can be used in
place of "Load" for a TextBox
OR, lacking that
2. Is there a way to add an event or mimic this Load event behavior?
OR
3. Is there a way to fully disable the Layout event handler inside
its own code so that is guaranteed only to fire once at the beginning
of runtime and not twice nor ever again?

Whoever answers this, thank you so much for your time. This has
driven me crazy.


Nov 15 '07 #3

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

Similar topics

1
by: keefah | last post by:
Hi, I can't seem to get past this problem, though I've tried multiple examples off the web. I've registered integrated Crystal (VS.NET 2003 Pro). I've made sure the assemblies are all there. I've...
2
by: Michelle | last post by:
Hello all, I recently inherited a SQL 7.0 Server db accessed by a 2000 Access interface. When I try to open "Shipping Check Out" I am greeted with the following: The expression On Load you...
11
by: bleedledeep | last post by:
I've been tracking down a memory leak using DevPartner 7.2 and what I am seeing is that calling XmlDocument.Load() leaks A LOT of memory. The following code is called when I click a button on my...
0
by: mmj | last post by:
If I am loading my reports in this fashion ReportDocument.Load("MyReport.rpt") Is there a way to do this and still have the .rpt file's build type be set to EmbeddedResource which makes it in...
1
by: Dominique Vandensteen | last post by:
I want to dynamicly load a type (typename is defined in the database). This type is located in the exe itself or one of the dll's in the directory with the exe file. When creating an instance...
0
by: Noozer | last post by:
Can the default event for a usercontrol be changed? I've created a usercontrol. I can add it to a form without any issues but when I doubleclick it, the IDE takes me to the LOAD even for that...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
4
by: parez | last post by:
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..
2
by: mvsmsh | last post by:
Hi , How can I load without copy in UDB V8/AIX , I don't want copy or backup after load. Are there any command in UDB , like Z/OS DB2 "repair tablespace nocopypend" ?
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.