473,701 Members | 2,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Load events happens at strange times

I have a Form (FV&C) containing a userconrtrol (CF&E)

I do a ShowDialog for the form and the form's Load calls a method of the
UserControl.

The first time I do this the usercontrol appears on the form as I'd expect
after the method had been run.

The second time I do this the usercontrol appears on the form as if the
usercontrols Load had last been run.

I peppered the code with writes and the following resulted.

Note that for the fist time, the usercontrol's Load runs before the form's
Load starts.

But, notice at the bottom of the list that for the second time, the
usercontrol's Load runs after the form's Load ends.

Does this make sense to you?

Any suggestions as to what is going on?

I need to have the CF&E Load run before the called method or better, if the
usercontrol remember from the last time, not to run at all.

Thanks
FV&C New Staring
CF&E New Staring
CF&E New Ending
FV&C New Ending
Call FV&C method
FV&C.ShowDialo g
CF&E Load Staring
CF&E Load Ending
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
FV&C Closing
FV&C.ShowDialo g Returned
Call FV&C method
FV&C.ShowDialo g
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
CF&E Load Staring
CF&E Load Ending
FV&C Closing
FV&C.ShowDialo g Returned

Dec 19 '05 #1
2 2020
**Developer** wrote:
I have a Form (FV&C) containing a userconrtrol (CF&E)

I do a ShowDialog for the form and the form's Load calls a method of the
UserControl.

The first time I do this the usercontrol appears on the form as I'd expect
after the method had been run.

The second time I do this the usercontrol appears on the form as if the
usercontrols Load had last been run.

I peppered the code with writes and the following resulted.

Note that for the fist time, the usercontrol's Load runs before the form's
Load starts.

But, notice at the bottom of the list that for the second time, the
usercontrol' s Load runs after the form's Load ends.

Does this make sense to you?

Any suggestions as to what is going on?

I need to have the CF&E Load run before the called method or better, if the
usercontrol remember from the last time, not to run at all.

Thanks
FV&C New Staring
CF&E New Staring
CF&E New Ending
FV&C New Ending
Call FV&C method
FV&C.ShowDialo g
CF&E Load Staring
CF&E Load Ending
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
FV&C Closing
FV&C.ShowDialo g Returned
Call FV&C method
FV&C.ShowDialo g
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
CF&E Load Staring
CF&E Load Ending
FV&C Closing
FV&C.ShowDialo g Returned


My guess is you are not using a form variable, but rather loading the
form directly. Using a form variable, you will then call New, and the
process should proceed as in the first portion.

Tom
Dec 19 '05 #2
Maybe the problem is because I use the same Form variable for two
ShowDialog's.
As normal with ShowDialog, the form is closed at the end of the first
ShowDialog run.
What happens the second time I do ShowDialog

I think that must be the problem.
I want to keep the form around because it contains data that I need.
So I do ShowDialog on the form
The form closes itself when finshed
I do ShowDialog later thinking ( maybe not thinking clearly) that my data
will still be there and the form will simply become visible.

In Declarations I do
Friend WithEvents mFormVolAndChap s1 As CAG.formVolAndC haps.FormVolAnd Chaps =
New CAG.formVolAndC haps.FormVolAnd Chaps

On menuitem click event I do

Console.WriteLi ne("Call FV&C method")

mFormVolAndChap s1.Action =
FormVolAndChaps .FormVolAndChap s.ActionType.Cr eateNewVolumeFo lder

Console.WriteLi ne("FV&C.ShowDi alog")

mFormVolAndChap s1.ShowDialog()

Console.WriteLi ne("FV&C.ShowDi alog Returned")

' It's the second time I click that I have a problem.

' I've noticed that the usercontrol Visible property is True the
first time and False the second time!


Comments?

I believe the above procedure would be OK if I were using Show instead of
ShowDilog - correct?
Thanks


"tomb" <to**@technetce nter.com> wrote in message
news:Dp******** *********@bigne ws6.bellsouth.n et...
**Developer** wrote:
I have a Form (FV&C) containing a userconrtrol (CF&E)

I do a ShowDialog for the form and the form's Load calls a method of the
UserControl .

The first time I do this the usercontrol appears on the form as I'd expect
after the method had been run.

The second time I do this the usercontrol appears on the form as if the
usercontrol s Load had last been run.

I peppered the code with writes and the following resulted.

Note that for the fist time, the usercontrol's Load runs before the form's
Load starts.

But, notice at the bottom of the list that for the second time, the
usercontrol 's Load runs after the form's Load ends.

Does this make sense to you?

Any suggestions as to what is going on?

I need to have the CF&E Load run before the called method or better, if
the usercontrol remember from the last time, not to run at all.

Thanks
FV&C New Staring
CF&E New Staring
CF&E New Ending
FV&C New Ending Call FV&C method
FV&C.ShowDial og
CF&E Load Staring
CF&E Load Ending
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
FV&C Closing
FV&C.ShowDial og Returned Call FV&C method
FV&C.ShowDial og
FV&C Load Staring
Called a method in CF&E
FV&C Load Ending
CF&E Load Staring
CF&E Load Ending
FV&C Closing
FV&C.ShowDial og Returned

My guess is you are not using a form variable, but rather loading the form
directly. Using a form variable, you will then call New, and the process
should proceed as in the first portion.

Tom

Dec 19 '05 #3

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

Similar topics

3
5233
by: Torrent | last post by:
When Trying to Load an XSLT File with the XslTransform i got a rather annoying Exception being thrown "System.Xml.XPath.XPathException: XsltContext is needed for this query because of an unknown function." It was annoying because I had checked created the whole document and tested it in Internet Explorer 6.0 and everything worked perfectly; no errors or warnings. After doing research i found out that most often times the error that i was...
1
2463
by: Jeffrey Kelso | last post by:
I am having an issue where doing a PostBack in ASP.NET is losing the form information. This is happening in a NLB environment with two servers using Application Center When a user selects an item from a DropDownList and then clicks a submit button, the Click event on the button redirects them to the value of the selected item. This works fine if you are on Webserver1 and the button click PostBacks to Webserver1. If you are on...
3
2628
by: Francois | last post by:
Hi, First of all sorry for the long post but I believe it is quite an interesting as well as advanced and complex problem. I have a problem with the checkbox control I have in my repeater. I am using a repeater that I bind to some data in the Page_Load method. That page is heavy and highly dynamic and the viewstate of the repeater and all the controls existing in that repeater are set to "False" as none of the information in the...
11
2358
by: Jason | last post by:
Hi I have a "problem" i have got a ASP.NET application. in this application i have included logging. in the logging i have logged how many seconds it takes for this application to fully load. i have placed these timing loggings in the Load and Init events on a typical aspx page. i.e. first line of code in Page_Load is DateTime dtStart = DateTime.Now; and the last lines of code are
12
4285
by: Dean Slindee | last post by:
My project has a main form (frmMain, the startup object for the project) and several other "child" forms that are painted within a large panel on frmMain. In each form's Form_Load event, a Weak Reference for that form is loaded into a global Hash table, like this: Dim wr As WeakReference = New WeakReference(Me, False) If Not hashTable.Contains(cfrmMain) Then
1
3818
by: dbagirltx | last post by:
We have done some testing with mixed and forgotten results. So I'm hoping that asking here can clarify some issues for us. Right now we do one weekly warm backup. Throughout the week there are multiple unrecoverable loads. We are tyring to come up with the best backup strategy for this system? It is a large dev data warehouse. What happens when a table is loaded unrecoverable and then we need to restore (no DDL has been done)? Can we...
3
12321
by: quoclinh | last post by:
I have an aspx page with code behind that has the initial page load code happens many times as user perform different action on the page, such as select a drop down list. To be more clear, consider the following code: protected override void Page_Load(object sender, EventArgs e) { if (!IsPostBack) {
4
2139
by: Joergen Bech | last post by:
Just out of curiosity: What is your favorite method of making sure that anything that happens on a form, only happens in response to a single, external event? Take the example below. I have made it as simple as I could: Put two textboxes on a form, paste the code and run it. The idea is that whatever is typed in one box is displayed in the other box, only reversed. This is a simple example of two repre- sentations of the same data on...
2
3114
by: GauravGupta | last post by:
i am displaying a table in page load whose data is fetched from database . it also check what data is to be displayed from data base by a session variable. and i have few button which change the session variable value. when i click on some button page load is called before button click event, so data which is displayed is according to previous session not the session changed by button click.
0
8737
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9084
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8936
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5905
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4665
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3104
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.