473,406 Members | 2,356 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,406 software developers and data experts.

how to close a vbnet winform when it's completely loaded

Hi.

I have a MDIchild form called Form1.
In Form1_Load code, the form populates a Listview control based on a
datareader, but I want to close the form inmediately and return to the
parent form, if there was a problem connecting to the database and
populating the Listview control.

I've tried something like this:

Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
MyBase.OnActivated(e)
Static myFormIsLoaded As Boolean
If myFormIsLoaded Then Return
myFormIsLoaded = True
Refresh()
If failed_to_populate_listview Then
Me.Close()
End If
End Sub

But Me.Close() returns this exception: "Can't call Close() while
doing CreateHandle()."

Does anybody know which event fires when the form is completely
loaded?
I need an event from which I could call the Me.Close() method!

I would appreciate any help.
Thank you.
Jul 21 '05 #1
4 2755
Hi Carolina,

In a midi form you can always use the me.parent, to get the parent form,
I am not that MDI expert however I think that me.parent.close will do what
you want.

When that does not work, or you have next time a questions about VB it is
better to ask that in the newsgroup

microsoft.public.dotnet.languages.vb

There are a lot who have done a lot with MDI forms.

I hope however that this works too.

Cor
Jul 21 '05 #2
Hi Carolina,

In a midi form you can always use the me.parent, to get the parent form,
I am not that MDI expert however I think that me.parent.close will do what
you want.

When that does not work, or you have next time a questions about VB it is
better to ask that in the newsgroup

microsoft.public.dotnet.languages.vb

There are a lot who have done a lot with MDI forms.

I hope however that this works too.

Cor
Jul 21 '05 #3
Why not create an exception if the listbox doesn't load and in that handler,
call me.Close. You can do this from within form_load.
"Carolina" <cc******@gmx.net> wrote in message
news:f4**************************@posting.google.c om...
Hi.

I have a MDIchild form called Form1.
In Form1_Load code, the form populates a Listview control based on a
datareader, but I want to close the form inmediately and return to the
parent form, if there was a problem connecting to the database and
populating the Listview control.

I've tried something like this:

Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
MyBase.OnActivated(e)
Static myFormIsLoaded As Boolean
If myFormIsLoaded Then Return
myFormIsLoaded = True
Refresh()
If failed_to_populate_listview Then
Me.Close()
End If
End Sub

But Me.Close() returns this exception: "Can't call Close() while
doing CreateHandle()."

Does anybody know which event fires when the form is completely
loaded?
I need an event from which I could call the Me.Close() method!

I would appreciate any help.
Thank you.

Jul 21 '05 #4
Why not create an exception if the listbox doesn't load and in that handler,
call me.Close. You can do this from within form_load.
"Carolina" <cc******@gmx.net> wrote in message
news:f4**************************@posting.google.c om...
Hi.

I have a MDIchild form called Form1.
In Form1_Load code, the form populates a Listview control based on a
datareader, but I want to close the form inmediately and return to the
parent form, if there was a problem connecting to the database and
populating the Listview control.

I've tried something like this:

Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
MyBase.OnActivated(e)
Static myFormIsLoaded As Boolean
If myFormIsLoaded Then Return
myFormIsLoaded = True
Refresh()
If failed_to_populate_listview Then
Me.Close()
End If
End Sub

But Me.Close() returns this exception: "Can't call Close() while
doing CreateHandle()."

Does anybody know which event fires when the form is completely
loaded?
I need an event from which I could call the Me.Close() method!

I would appreciate any help.
Thank you.

Jul 21 '05 #5

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

Similar topics

4
by: Carolina | last post by:
Hi. I have a MDIchild form called Form1. In Form1_Load code, the form populates a Listview control based on a datareader, but I want to close the form inmediately and return to the parent form,...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
0
by: hello_world | last post by:
I have a winform containing a TabControl with multiple TabPages. Each TabPage in turn contains several controls (Labels, TextBoxes ...). Now, when I load my form or switch TabPages, the controls...
2
by: howa | last post by:
Should we add document.close after each time when we used document.write() ?
3
by: Torben Laursen | last post by:
I have a COM shared add-in written in C# that I use in Excel. One of the thinks that the user can do is to open some winforms. The problem that I have is that the first time the user opens a...
14
by: Monty | last post by:
Hello, I have created a solution which has both a web UI and a winform UI, the latter is just for administrators. The Web UI (a Web Application Project) and the winform project both...
5
jamesd0142
by: jamesd0142 | last post by:
My form is called 'PasswordChange' i can say: PasswordChange.hide() PasswordChange.Show() and they work correctly. but when i say:
9
by: Victory | last post by:
Hi, Our group has to develop a new UI. We are using a third party and have them develop this since we don't have a lot of experience in doing this. We want it to be accessible through the web...
4
by: Aric Green | last post by:
At work we have upgraded to Office 2007. Our users are getting an error message at random while using Excel and Word. “Microsoft Office (Appname) has encountered a problem and needs to close. We...
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
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?
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...
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
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...
0
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...

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.