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

Form: calling Close() method in Load event.

Hello,

I try to call the Close( ) method in the Load event of a Form, but it
doesn't seem to work. Any idea why not? And how do I close a Form in it's
own Load event?

Private Sub frmForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Throw New Exception("Close me please.")
Catch
Me.Close()
End Try
End Sub

Thank you.
Nov 21 '05 #1
6 3177
Qwert,

Your code seems to work for me. Does your form load instead of closing? Are
you getting any error messages?

Kerry

"Qwert" wrote:
Hello,

I try to call the Close( ) method in the Load event of a Form, but it
doesn't seem to work. Any idea why not? And how do I close a Form in it's
own Load event?

Private Sub frmForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Throw New Exception("Close me please.")
Catch
Me.Close()
End Try
End Sub

Thank you.

Nov 21 '05 #2
"Qwert" <no**@nosp.com> schrieb:
I try to call the Close( ) method in the Load event of a Form, but it
doesn't seem to work. Any idea why not? And how do I close a Form in it's
own Load event?


Your code works fine for me on .NET 1.1 SP1. What version of .NET are you
using and how are you showing your form?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
No error messages. When I call Me.Close() in the Load event, the form
doesn't close. Everything contineous like I didn't call Me.Close().

Your code seems to work for me. Does your form load instead of closing?
Are
you getting any error messages?

Kerry

"Qwert" wrote:
Hello,

I try to call the Close( ) method in the Load event of a Form, but it
doesn't seem to work. Any idea why not? And how do I close a Form in it's
own Load event?

Private Sub frmForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Throw New Exception("Close me please.")
Catch
Me.Close()
End Try
End Sub

Thank you.

Nov 21 '05 #4
I have both 1.0 and 1.1 installed, VS.NET(2002, v7.0) says it's using 1.0.

I show the form with the .ShowDialog() method.

Your code works fine for me on .NET 1.1 SP1. What version of .NET are you
using and how are you showing your form?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Qwert,

I just tried your code in VS.Net 2002 and it did not work. When I tried it
in VS.Net 2003 it worked fine.

The Try - Catch block worked in Form_Load, but not the Me.Close()

Kerry Moorman
"Qwert" wrote:
I have both 1.0 and 1.1 installed, VS.NET(2002, v7.0) says it's using 1.0.

I show the form with the .ShowDialog() method.

Your code works fine for me on .NET 1.1 SP1. What version of .NET are you
using and how are you showing your form?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #6
Hmm and one more m. Weird.

Then I have to do it another way. More work.

Thank y'all for the answers and the testing.

Qwert,

I just tried your code in VS.Net 2002 and it did not work. When I tried it
in VS.Net 2003 it worked fine.

The Try - Catch block worked in Form_Load, but not the Me.Close()

Kerry Moorman
"Qwert" wrote:
I have both 1.0 and 1.1 installed, VS.NET(2002, v7.0) says it's using
1.0.

I show the form with the .ShowDialog() method.

> Your code works fine for me on .NET 1.1 SP1. What version of .NET are
> you
> using and how are you showing your form?
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #7

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

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
5
by: David Smith | last post by:
Under a certain circumstance, I want a form to display a messagebox in the load event, and then close. But apparently I cant close a form in the load event. Any ideas? Thanks
6
by: nadeem_far | last post by:
Hello All, I am working on a .Net desktop application and I am having problem displaying a form. I am using C# and version 1.1 of the framework. here is how the code looks likes and I will...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
6
by: Tom | last post by:
Is there ANY easy way to close a MDI Child form in the middle of it's load? For instance, during the Load event I find a need to close the form (for whatever reason - maybe the user isn't ready for...
2
by: **Developer** | last post by:
I have a little more info about this problem I can't seem to solve! I know it'll take a minute to study the lising but if you like to sove puzzles there is one there. I have a Form (FV&C)...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
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: 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: 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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.