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.
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.
I have been making a webbrowser for a while now, everything works well, except i am unable to make the 'open in a new window' button work right. So far i have managed to get a new instance of my form to open with the right url, but i am unable to keep that new form open when the orginal parent form closes.
Code:
Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow e.Cancel = True Dim Href As String
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???
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
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?
I have two forms , first one is search and second is showing the data searched by first form search criteria. When the search query runs it takes lot of sql server resources, so I have passed that query to second form, it searches in database and shows the results. But if the results are not found I wish to close the second form in Form load event. As Second forms form load event searches for the record. I tried to use SecondForm.close in SecondForm.load event but failed to do so.
Private Sub txtAIT_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtAIT.Validating If txtAIT.Text <> "" Then
[Code]....
In form I have a close/Cancel button, and I set Causes Validation = false, and on its Click I used "Me.Close", but form can not be closed.
Button Works fine, but form can not be closed until text field has been validated.
in my visual basic 2008, i have create like a hospital check form like just pressing some keyword the person data automatically open to another form and the current form will close since i am new to the visual basic 2008 i would like to ask what is the coding work to save the data of a person and how to retrieve a data of that person by pressing the keyword?
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.
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
I have two forms. The first one opens the second one after all fields are filled out successfully. The problem I am having is I want to close the first form when the second form is displayed, but every time I try using frmCustomer.Close() when the second page (Result) loads, it completely closes the entire application.What am I doing wrong? What is the correct way of doing this?
I have two forms and a button on the first form. What i want is when i click the button the second form to show and the first one to close.But this isn't working with:
Basically during the form load event i carry out some checks to make sure i have database connection and a valid login, if these items fail i catch the exception and display a messagebox and change a boolean variable to false.It then goes back to form load where i have an if statement which is if boolean variable = false then me.close
Trouble is this runs through to the conclusion of the form_load sub and then attempts to load and throws an instance of an object type exception.I kinda understand the logic that i am trying to close the form before it has loaded, so put the close command in the form_activated routine, however this still eventually sends me back to the form load sub and tries to load the form, and then throws the same exception.
I have been having a problem with closing only one of my forms for quite some time now. I will normally have a splash form that I want to close (and the main form to show) after the splash form is clicked. When I use frmSplash.close() ,in the frmMain_load procedure, it closes both forms; the same occurs if I try using me.close() in the frmSplash_click (even if it's after the frmMain.show).
I have a form that is showing video footage of 4 ip cameras and on top of that it is also getting 2 scale readings from my scale. The problem is that when I try to close the form using the me.close command the form freezes for some time and then closes. and then when I want to run it again it freezes for some time before it loads really well.
I have a form open (UpdateResponse) and the user wants to update a datagrid. So they click on a button to update the datagrid (and the database) and then they receive a message (ResponseUpdateConfirmation), which is another form, telling them that the update was successful. I want to show this message over the original form so that the user can see the datagrid being updated beneath the message. This all works.But then I want the user to click "Continue" on the pop-up message form after which I want the original form (UpdateResponse) to close and a new form (CadLogIn) to open (and the confirmation message to close). And no matter what I try, when the user presses continue, the confirmation message form will close and the new form will open. But the original form still stays open! [code]
I have a form open (UpdateResponse) and the user wants to update a datagrid. So they click on a button to update the datagrid (and the database) and then they receive a message (ResponseUpdateConfirmation), which is another form, telling them that the update was successful. I want to show this message over the original form so that the user can see the datagrid being updated beneath the message. This all works.But then I want the user to click "Continue" on the pop-up message form after which I want the original form (UpdateResponse) to close and a new form (CadLogIn) to open (and the confirmation message to close). And no matter what I try, when the user presses continue, the confirmation message form will close and the new form will open. But the original form still stays open![code]
I'm coming from VB VS 6.0, so a bit behind the times, I tried VB.NET and hated it. Now I'm back and using VB VS 2010 Express Edition, not bad a little closer to 6.0 that I can recall with some of the .NET I didn't care for.
I can't see to find out how to make my splash form close without killing the whole program, I've looked it up on google and done all the different code variations that I've found and nothing seems to work.[code]...