VS 2008 : Modal Form Hide Instead Of Close - Main Form Does Not Close

Mar 20, 2009

I have a main form that has a button with which a smaller form is shown. Think of the smaller form as the Find/Replace dialog in many applications, such as Notepad. It's important that the form is (what I believe is called) modal. What I mean is that it always stays on top of the main form. I ensure that by calling the Show method with "Me" as the owner argument. Whenever the small form loses focus it will not disappear into the background but stay visible (albeit out of focus). If you don't understand open up Notepad and have a look at the behavior of the Find/Replace dialog.

Here's my problem: instead of actually closing the form when the X is pressed, I want it to simply Hide itself, so its position and the state of any controls (checkboxes etc) is preserved automatically.To achieve this I simply cancel the FormClosing event and Hide it:

vb.net
Private Sub Form2_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

[code]....

To show the form, I use the following (note the (Me) to make the main form the owner of the form; this ensures that it remains visible even when it is out of focus):

vb.net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show(Me)
End Sub

Now. When I run my project, and open the Form2 (small form), then hide it again (by 'closing' it), I can no longer close the main form (Form1)! It seems the main form cannot close when the small form still exists (albeit invisible)...?? When I don't use the Me argument in the Show method, I don't get the behavior I want. I know I can set the TopMost property to True but that will also cause it to become visible on top of all the other forms, even windows not part of my application.

View 8 Replies


ADVERTISEMENT

VS 2008 When Close The Main Form All The Forms Close?

Aug 30, 2009

my web browser is my main form and it has a number of sub forms , how can i set it that when i close the main form my sub forms dont close ?

At the moment when i close the main form all the forms close

View 2 Replies

Close A Modal Form From Who Initiated Modal One?

Feb 25, 2011

I have a parent form (form1), which is calling a second form (form2) as modal.[code]...

No form2 is modal. Closing this form2 from the form itself is clear.But how can I close the form via myform2.close from form1 via an event handler?

View 6 Replies

.net - Main Form Minimized When Modal Dialog Calls Me.Hide()?

Mar 22, 2011

sometimes (not everytimes), when I call the Me.Hide() in a form, which I called with .ShowDialog(), the main form, which called this dialog minimized.

View 2 Replies

Get A Button On Form A To Open Form B And Then Close (not Hide) Form A When Clicked?

Jun 12, 2009

get a button on form A to open form B and then close (not hide) form A when clicked?Background: I am coding a VSTO application for Excel in VB2008.

Private Sub FormAButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles FormAButton.Click
Dim FormB As New FormB

[code]....

View 1 Replies

VS 2010 Sub/Child Form Close When Click On Main/Parent Form?

Jun 5, 2012

i am having some trouble in my Windows form application. i have 2 forms1st Main / Parent Form2nd Sub / Child Form (Menu)

View 7 Replies

[2008] Notify Icon When The User Clicks The Close Button That It Doesn't Close The Form?

Jan 17, 2009

I have set up a notify icon for my form. I want to make it so that when the user clicks the close button that it doesn't close the form it just takes it to shows the notify icon. They can exit the program from the notify icon. Can someone tell me how to keep it running?

View 2 Replies

Display The Main Form And Close The Login Form?

Sep 2, 2011

VS2010 VB.NET windows form app I have a login form that is my startup form.when uer hits OK I display the main form and close the login form, like this:

PrivateSub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
frmMain.Show()Me.Close()EndSub Problem is the application closes with me.close. Why? How can I close only the login form and leave the main form urnning???

View 3 Replies

How To Close Main Form

Feb 23, 2009

I can't seem to get the right code to close the main form

View 3 Replies

.net - Disable The Close Button Of The Main Form?

May 30, 2011

Is there a possible way in VB.NET to disable the close button of the main form as I've seen in many installer! I don't want to hide it, I want to completely disable it!

View 3 Replies

Close Login And Open Main Window Form?

Feb 15, 2012

I am having a difficulty in this login form that I have made. The same as the premade template login in VB 2008 which I am using right now.Here's what happens when I run the program Log in form open > Log in successful > Main window appears *The login form still does not disappear.

I tried hiding it via me.hide() Log in form open > log in successful > Main window appears > log in form disappear.*Now the problem is that I cant close the whole application because the login form is still there only hidden. Again I tried putting in the "EXIT" button the code me.close() login.close()Log in form open > log in successful > Main window appears > log in form disappears > Exit application *Now everything seems to be ok now and then I found another problem.Instead of clicking the exit button I tried clicking the X button on the main window. There I found out that it only closes the main window. Therefore not closing the whole application because the login form is still hidden.

View 2 Replies

Close Only The Main Form In 2010 Without Terminating The Application?

May 7, 2011

I have a login form which I need to close without the entire application being terminated. I tried using Me.Close() , Me.Hide() as well. The login form is used as the main form as well.

View 2 Replies

VS 2005 Show() - Hide() And Close() Form Several Times?

Jul 16, 2009

[Code]....

here i am dealing with only two form,so if i add form1.close() in the form2 button click event then it might wok. but what if i deal with many forms and i need to show and hide them several times?

View 2 Replies

Stackoverflow Exception Thrown When Calling Me.close() On Main Form

Apr 3, 2009

I have done some reading and it seems that this error comes from recursive calls but I have not done anything in my form_closing handler except for call me.close, that's it.

So I don't understand how this exception has entered my project. All of my data and functionality is still working as I expect. It just seems to throw this exception when I try and exit my project.

what I could check to prevent something like this from happening?

View 3 Replies

Kill A Form After FormClosing Event Is Overridden To Hide Rather Than Close?

Apr 12, 2010

I have a simple Windows Form that hosts property controls at runtime. When the user clicks Close [X] I want to keep the window and its contents alive rather than killing it by handling the FormClosing event, canceling the event and simply hiding the form.

That's fine but at close of the application I need to actually close the window. I implemented the below but it feels kludgey. Is there a simpler, more clever way to handle this situation? (The form's controller calls KillForm explicitly after it receives a closing event from the main window.)[code]...

View 1 Replies

How To Close One Form In A Project And Note The Entire Project When Using Me.close() In Visual Studio 2008

Mar 22, 2010

I am really new to Visual Studio and VB and I am having trouble closing a single form:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.Close()
End Sub

When I use Me.close() associated with this button it closes the entire project and not just the single form can anyone.

View 2 Replies

Interface And Graphics :: Hide / Show - Doesn't Dispose When Close Form

Oct 23, 2008

Is there a way to have a form within a program that doesn't dispose when you close it? I have a form in my project and a menu item to show it. When I declare the form globally and show in menuItem.click, then the click event breaks because the form no longer exists. When I declare the form within menuItem.click, then this creates a new form every time I click and that's not what I want.

View 1 Replies

.NET End Vs Form.Close() Vs Application.Exit Cleaner Way To Close One's App?

Feb 12, 2011

sometimes, when I use Form.close() when debugging my program, although the form is closed, the application is still running. I noticed this behaviour when using the msgbox function.

View 3 Replies

Vb2010 Close Of The First Form Close The Application Even If A Second Form?

Feb 14, 2011

I try to transfer a vb6 application to vb2010. In the vb6 I start with a login panel that the user enter uid and password autenticate with the DBServer if ok show application main menu and close the login form. the order of the me.close() after the mainform.show() does not change, The application ends.

View 5 Replies

Forms :: When Me.close() Doesn't Close Form

Mar 2, 2009

I have a situation where me.close() doesn't close the form. I have a form with a button with the code seen below. What happens when the button is clicked is the new form shows, but the original form(calling form) is still there. When I go into debug mode, I can see the me.close() execute, but nothing happens (calling form stays open). When I close the second form both forms close. If I comment out the call for the second form to open the first form closes without problem.

Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click
Dim f As New frmOrder3

[Code].....

View 1 Replies

Calling Showdialog() On A Form - From The Main Form's OnLoad Event Makes The Modal Dialog Go Away After A Few Seconds?

Aug 7, 2009

I'm having an interesting issue that I can't reproduce on a different project, but can consistently on this one. I have no clue what might be causing it, but am hoping that someone may have seen it before.

I have a main form, from which I run a series of checks. On this form, I have a listview control. Because of some issues with the refreshing of this listview control, I had to create my own messagebox. It's just a form that displays some text ( it also happens to look nicer than MsgBox; in my opinion, anyways ). It's been working great for months, until recently.

My problem is that on my main form's load event, I run this check, which returns an error within a try/catch block. I then call my custom messagebox with a message. It in turns calls it's ShowDialog() function.

In any other situation ( after the main form has been loaded ), I have no problems. The messagebox goes on the screen and behaves appropriately ( ie: waits for my input and acts as a modal dialog ( stops execution of my main form's thread ) ). However, on this onload event, my messagebox comes up and goes away almost immediately afterwards.

I've traced it all the way to the showdialog() call. For no explicable reason, it appears to skip right over this call, without me doing anything on the form.

Here's what the inner trace looks like ( when I put a breakpoint on the onclosing event for this messagebox form ):

CODE:

View 10 Replies

Find When Dialog / Modal Form Is Shown For My Main Form?

Feb 3, 2010

I want to be able to check if there is currently a dialog or modal form shown for my form so that I can close it.
Is there a way to do this?

View 1 Replies

VS 2008 Close Current Form And Show Different Form?

Sep 4, 2009

When I use

Me.Close()
Form1.Show()
It closes the whole app.

How would I change it so that it only closes the current form while opening a new one? EDIT: I put [Not Resolved] Because I accidently pressed the resolved thing

View 8 Replies

C# - Clicking "X" In Form, Will Not Close It But Hide It?

Jul 14, 2010

how can i make my Form not to close but to Hide when user click on the "X" button on the form?

As i have a NotifyIcon that contain an Exit menu which actually does the Form Closing (i don't want the Form's "X" to close the form but to hide it).

View 3 Replies

VS 2008 A Form Don't Close?

Jun 12, 2011

well, I have a Main form that lauches sometimes a secondary form with the

frmAlert.Show()
code... (FrmAlert.TopMost = True)
some seconds after, from the Main form I launch the

[code].....

View 12 Replies

How To Temporarily Hide A Modal Form

Mar 29, 2009

I've created an Excel COM add-in that has several forms. The application has the following forms:

FormA (Modeless): Excel.Application is parent
FormB (Modal): FormA is parent
FormC (Modal): FormB is parent

[code].....

View 3 Replies

VS 2008 A Form Doesn't Close?

Jun 3, 2010

I have a Main form that lauches sometimes a secondary form with the

frmAlert.Show()
code... (FrmAlert.TopMost = True)
some seconds after, from the Main form I launch the
frmAlert.Close()
but the form don't closes itself!

[Code]...

to activate the form, but it don't closes itself, both with .Close or .Dispose or .Hide code even if it is activated by frmAlert.Select()... the FrmAlert.Visible property remains = False

View 2 Replies

VS 2008 Form Close Vs Dispose

May 6, 2009

I am using VB.NET (Visual Studio 2008) and thus .Net framework 3.5. I have developed an application which has a MDI form and then has several other forms, most of which are shown using form.showdialog and some set of forms are shown using form.show. Whenenver a form (shown using form.showdialog) was closed (usually by clicking on a button (OK or Cancel)) I wrote code Me.dispose. After careful testing and R&D I figured this caused flickering on the screen. There use to be a flicker on the screen and it looked weird.

[Code]....

View 5 Replies

VS 2008 Open One Form And Then Close Another?

Dec 21, 2010

i've tried

On Form1
form2.show
me.close

[code].....

View 2 Replies

RTF Close - Add A Close Button To Menu Strip That Will Just Close The Currently Opened File

Jan 16, 2009

I'm currently in the process of building a text editor type program, and have run into a brick wall. I haven't done VB in years, so I may just need a little reminder on some things. I have coded everything so far as far as opening files, saving them, changing fonts, colors, etc. However, I'm looking to add a Close button to my menu strip that will just close the currently opened file, and not the entire program, while also ask the user if he/she would like to save before closing the file, and then if they select yes, it will show the save dialog, and if not, it will go ahead and close the currently opened item.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved