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

Hide main form instead of closing

I would like to make it so when a user clicks the X in the upper right
corner it hides the form instead of closing it. I have an icon in the
system tray, and other forms running. If the main form closes, these exit
as well.

Can this be done?

Matthew
Nov 21 '05 #1
5 8087
In the closing event of the form, do something like this:

Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub

Note that you'll then need to use Application.Exit( ) to exit the
application since closing the form is not going to exit and also calling
Form1.Close won't help since this also fires the Closing event.

hope that helps..
Imran.

"Matthew" <tu*************@alltel.net> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
I would like to make it so when a user clicks the X in the upper right
corner it hides the form instead of closing it. I have an icon in the
system tray, and other forms running. If the main form closes, these exit
as well.

Can this be done?

Matthew

Nov 21 '05 #2
Matthew,

This is very bad programmers behaviour and your users will not like you.

They are used to there normal habbits, what you want to do is making a car
go to the left when the wheel is turned to the right and let the car speed
up when you push the brakes.

Just my 2 eurocents

Cor
Nov 21 '05 #3
> In the closing event of the form, do something like this:

Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub


Perfect! Thanks for your help.

Matthew
Nov 21 '05 #4
> In the closing event of the form, do something like this:

Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Me.Hide()
e.Cancel = True
End Sub


Perfect! Thanks for your help.

Matthew
Nov 21 '05 #5
> This is very bad programmers behaviour and your users will not like you.

They are used to there normal habbits, what you want to do is making a car
go to the left when the wheel is turned to the right and let the car speed
up when you push the brakes.


Thanks for the advice. I will keep it in mind.
I think in this instance the users would be disappointed if the [entire]
application closed.
However, I will definitely listen to user feedback and take that feature off
if they don't like it.

Matthew
Nov 21 '05 #6

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

Similar topics

13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
3
by: Steve | last post by:
I am new to .Net and Visual Studio, I have a login form and my main application form. When I login I want to call the application form, and dispose of the login. I have tried doing something...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
4
by: Matthew | last post by:
The following code does not hide the form. Any ideas why? Also, is there a workaround? I have VB.NET 2003. I have a system tray icon, and want to have that be the only thing showing when the...
4
by: Maarten | last post by:
Hi I'm trying to make something i tought is was simple if i press the cross on the childform to close it, i want it to hide. but when i press a button on the parrent i want to close the child....
2
by: gene kelley | last post by:
I have a dialog form, frmDetails, that is opened from the main form: frmDetails.ShowDialog() The only way I have provided to close this dialog is via the "X" button. If frmDetails is just...
5
by: Thelma Roslyn Lubkin | last post by:
I am still having trouble trying to use a popup form to allow user to set filters for the main form. The main form is based on a single table. The popup contains 5 listboxes, so the user can...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.