Can't Close A Form in C#

I've tried the Close term by itself, where I get a little note that comes up saying "this closes the form."
I've tried this.Close()
I've tried Application.Exit()
These are all commands I've given to a button to Exit my application and nothing works.  The button does nothing.

If you call Close() (or this.Close()) inside a form then it will close the form.  If the form you close happens to be your main form (the one that was passed to Application.Run in your entry point) then the app will terminate.  Calling Application.Exit
will cause the app to close as well.
When a form is closed it raises the FormClosing event.  Anybody can hook into this event and prevent a form from closing so calling Close doesn't guarantee the form will close in this scenario but for the general case it works.
It sounds like to me that your not actually executing the code that calls Close.  Put a breakpoint on the Close call and verify it is being hit.  If it isn't then you need to modify your code such that whatever method contains the call to Close
is actually being called.  In most cases it is being done when you click a button so make sure you have hooked up your button's click handler to the button either programmatically or via the designer. 
Michael Taylor
http://blogs.msmvps.com/p3net

Similar Messages

  • Infopath: Rules run before Code...So Can we close the form through Code?

    Hi,
    I have a form with a couple of buttons. Clicking on any of the buttons first executes the RULES and then jumps to execute the code in the FormCode.cs file for the button click event. However, if I have "Close the Form" as one of the Rules for the button, the code does not execute. So, is there a way that I can close my Infopath fom after executing the code instead of closing from the RULES? Also "The form has been closed" is the message which pops up after closing form through rules. Can we redirect to the form library instead of showing this message?
    I tried to execute everything through code in FormEvents_Submit. It works fine if I have a single submit button. But how would i differenciate if there are multiple buttons like Approve, Reject etc.
    Thanks !

    Hi Aanu,
    Thanks for the reply.The proposed solution in the thread is to use;
    this.Application.ActiveWindow.Close();
    or
    thisXDocument.View.Window.Close(true) in order to close the form.
    Both of them don't work when I try to use them in Visual Studio. It complains of a missing namespace.
    Did this approach work for anyone?

  • Can't close form

    HI,
    I've got a big application in forms 4.5 with Oracle 7 and Oracle 8i. I transform this application in Forms 6i, my application can run and the communication with the database is OK, but i can't close it (any form) this error system message appear immidiately
    ifrun60.exe - Image incorrecte (i'm french)
    the application or the dll :c:\WINNT\System32\user.exe is not a valid Windows picture. Virify with your installation floppy. (Sorry for my translation.)
    This message appear when i want to do an exit_form with this application by some function. The application test Bankapp run normally, and this message appear with an OS W2K or Win NT4 pack6. When i try to do an DO_KEY('EXIT_FORM') the application run with the CPU at 100 % and never stop. When i try to do an EXIT_FORM without passing to my function, the application do nothing.
    I don't know what to do.
    thanks for your help

    This forum is for general Oracle Forms questions. Please post your question in the General EBS Discussion forum. If you have a general Forms question, by all means, ask it here! ;-)
    As you are clearly working with the Oracle Enterprise Business Suite (EBS) you are going to want to become familiar with the Oracle Applications Documentation library. Select your EBS version and then scroll to the Standards section and review the following documents:
    <ul>
    <li>Oracle Applications Developer's Guide
    <li>Oracle Applications User Interface Standards for Forms-Based Products
    <li>Oracle Application Framework Personalization Guide
    </ul>
    Craig...

  • How can I close a category in the form central form without closing it as error?

    How can I close a category in the form central form without closing it as error?

    I'm still not sure I follow - let me see if this is right.  You want to have users signing up for something using a FormsCentral form and then when something is full you'd like that section to show as "Closed" or full so nobody else can sign up for that particular event/day/time?  If that is the goal FormsCentral does not have any logic to close certain portions of the form.
    Thanks,
    Josh

  • Can I get the former version of Firefox back? The updated version stalls while browsing several times a day. I then have to close and restart.

    Since updating Firefox, several times a day browsing will 'stall'. I have to close the browser and wait several minutes before I can restart it. Can I get the former version back? Please.

    Fx 3.6.19
    http://www.mozilla.com/en-US/firefox/all-older.html
    As a matter of interest what is this in your User Agent String? -
    GACID=dfc_1689; LTID=1689)

  • Unable to close web form.

    Here is a typical 11g forms development session for me.
    1. Create/modify a form using Forms builder on my PC.
    2. Transfer the form to the Solaris box.
    3. Compile the form.
    4. Open the form on my web browser.
    5. With the form still open, repeat steps 1-4.
    I have done it this way for years using 10g but 11g frequently freezes the form displayed on the web.
    I have to kill the browser and start all over.
    If I close the form on the web first, there is rarely a problem.
    Also, when a newly compiled form is run on the web for the first time, the canvas colors are all white !
    I can close and re-open the form with no other side effects.
    Do you think this may be a Java setting issue or what ?
    Thanks for your interest.
    Mike

    Mike,
    I have done it this way for years using 10g but 11g frequently freezes the form displayed on the web.I have to kill the browser and start all over.>
    Curious; I have always not done it this way! :) In my experience, and I've been working Oracle Forms for a lot of years, I have found that it is a "Best Practise" to always close an instance of a Forms Runtime rather than try to refresh a newly compiled version of a Form in the Forms Runtime instance. In cases where you don't do this, your browser session typically dies (4 out of 5 times) and you have to kill the browser session completely and start over. I've followed this method since my early days developing with Forms 4.5. In the rare instances where your Forms session doesn't freeze - often times the browser simply displays the same edition of the Form and not the new compiled edition.
    Do you think this may be a Java setting issue or what ?No, I think it is simply a case of the Object is already in use and trying to refresh the instance of the object with a newly compiled Form locks the object rather than refreshes the object. This was true with the old client installed Forms Runtime and I have found this to be true with the new Web Forms Runtime.
    All of this is based on my personal observation and experience, so this is just my opinion. Perhaps someone from Oracle (like Michael Ferrante) could elaborate on this. :)
    Craig...

  • How can I save a form with database connections with the info w/o requiring the connection again?

    I have a form in LiveCycle ES2 that has an ODBC connection to an Access 2007 database.  The form works great and all the data populates the form just fine, but next I need a way to save the generated form with the data so it can be sent and signed by people who won't (and can't) have a connection to the database.  I am developing on a Windows 7, 64 bit machine and have Adobe Acrobat X Pro, and Adobe Reader X.
    Any help or suggestions would be appreciated.
    Thanks

    Thanks for the quick response.  I tried saving the form as Reader Extended in Acrobat Pro, but if I close the form I saved as extended, it still prompts for the data connection.  Is there some setting in Adobe LiveCycle in the properties that maybe needs to be set?  I have it set as a Dynamic XML Form.  In form properties, there is a tab called data binding, should I have "Allow binding to data not defined by the default data connection" checked?  Wasn't sure what "Add data nodes inside the filtered data hierarchy" would do either.

  • How to close a form within script

    Hello,
    I'm using Adobe LiveCycle Designer v 8.2 to develop an Order form. I'm fairly new to developing in LiveCycle, and would like to ask the following question that I couldn't find an answer to elsewhere.
    I'd like to know if it is possible to close a form down within a script, if certain conditions are met/not met. Specifically, when my form loads I am testing the user's version of Acrobate Reader. If it is not above the stated version, I would like the form to close down. At the moment, it displays the warning message correctly but then continues to try and load the form.
    I guess the JavaScript equivalent of Me.Close() is what I am after
    if 
    (xfa.host.version < 8.101){
    xfa.host.messageBox("Your version of Adobe Acrobat Reader is not recent enough to use this form.",
    "Wrong version of Adobe Acrobat", 1);//Code to close form to go here
    Can anyone help?
    Thanks
    Matt

    You will be able to close the form but you will not be able to close the Reader application. The command you want is event.target.closeDoc(). This will close the currently active Document. Note that if you are diosplaying in a browser then it will not close the doc ....it will only work form the Reader/Acrobat applications.
    Paul

  • Can't close a window in html or JS

    How can I close a "child" window opened from a "main" window in html or JS without resorting to asking the user to close the "child" browser window? I think I have tried just about everything. I have tried opening the "child" window by an tag and with JS. I can get the "child" window to open but cannot seem to return to the unchanged "main" page. I know I must be doing something wrong.

    <form> should be inside the body element.
    <html>
    <body onClick="window.close(self)">
    <form>
    Click here to return to entry form.
    </form>
    </body>
    </html>
    There's no immediate need for a <form> element. You can use a pseudo button. Simply give the visitor something to click on.
    BTW the browser "back" arrow is dimmed in the child window in IE, Firefox, and Safari.
    When a webpage is opened in a new window there's nothing to go back to.

  • How can i close a modal window?

    Hi, everybody
    My question is in the subject, but i4ll repeat it again.
    How can i close a modal window in forms?. I4ve tried with hide_window but it doesnt closed itself.
    Please help me one again.
    Thanks.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JAMIE MCPHIE ([email protected]):
    There is a bug with Oracle Forms where you can not use the close button "X" on the window title bar. You need to create a button on the window that will close the form.<HR></BLOCKQUOTE>
    Jamie
    You are right in the fact of the programmer must make a exit mechanism. However, this is not a bug, this feature is related to the management of this windows type (modal). Bye
    null

  • How to close current form but leave calling form open

    My case is like this, I am working on one form. It have 2 functions. One is serach function, let us call it A, the other is display/entry function, let us call it B. I first start window A to search record. From that record I open window B, when I close window B, I want to leave window A open so I can start a new search.
    Right now, when I close widows B, window A closed too. How can I close only window B. I tried both APP_NAVIGATE.EXECUTE and FND_FUNCTION.EXECUTE but did not work out.

    Thank you very much.
    The problem is how can I find out what is the module name or window name. This is a heavily custom Oracle Apps form CSXSRISR. It is quite big and I just got lost into those data block/trigger stuff.
    Is there a easy way to find out the module for each window?
    Thanks

  • How do I close a form

    I have a form, which needs to be initialized when I change worksheet. Is their a code which finishes the job: UserForm_Terminate?
    :) Søren

    Typically the purpose of a Form is to display information to the user and accept inputs. When done the User will close the form with little x or click a Close button on the form which calls
    Unload Me
    If you want to close the form, perhaps after some sort of timeout, there are different ways depending whether you have shown the Form as Model or Modeless.
    If you showed it as Model your code loaded the form is suspended
    UserForm1.Show ' code stops here until the form is closed
    The only way to close the form is via code in the form, typically called by the user.
    Code that's called by buttons in the form works normally, and at any part of that code can branch off and do
    Unload Me ' code returns to the line that loaded and showed the form
    However things are different with modeless forms
    UserForm1.Show vbModeless ' code continues until it terminates
    In another routine (not in the form) you can close the form like this
    Sub test()
    UserForm1.Show vbModeless
    End Sub
    Sub CloseForm()
    Dim uf As UserForm
    For i = UserForms.Count - 1 To 0 Step -1
    If UserForms(i).Name = "UserForm1" Then
    Unload UserForms(i)
    End If
    Next
    End Sub
    Note the index of the first userform is zero.
    Another and perhaps better way is to set a reference to the form when loading it, and use the same reference to unload it. I hesitate to give an example because it's important to ensure all object references are cleaned up in all scenarios.
    Also look at the form's QueryClose event

  • Uncheck the "Close Other Forms" option under the Tools menu programmaticaly

    Hi,
    I have a standard Oracle form open, and I want to open my own custom form, leaving the standard form open, so users can navigate back and forth between the two. I can accomplish this, but I need to go to the Tools menu and uncheck the "Close Other Forms" option. Just wondering if there's a way to do this programatically? Thanks.

    Hi,
    Do you want to make the option 'not visible' or 'visible but not enabled'...?
    For the first option you probably would need to do form personalizations...
    For the second option you can refer to the following metalink note... "Note ID 264461.1"...
    Thanks and Regards,
    Raj

  • Can a reader enabled form do this ... ?

    I have a flowable Dynamic PDF form that pre-populates form fields based on a schema , etc. <br />It was designed using Live Cycle Designer 8.2 and Acrobat 9.0 . <br /><br />When I am using it with Acrobat - I usually go to <Forms> ... <Import Data> and select the file that I need to load using the file browser dialogue - <br /><br />Can a Reader enabled form - also do this -???????<br /><br />Can you recommend a good close alternative to this capability if tit is not available in Reader 9.0 ?<br /><br />Thanks

    It's not about server use. Have you read the information on creating plug-ins for Adobe Reader?
    There is a process you need to go through, called the RIKLA process ("Reader Integration Key Licensing Agreement"). Reader will not load plug-ins unless they have a specific certificate embedded in them, and Adobe will not give you this certificate until you have had your plug-in reviewed by their RIKLA team. There is also a cost involved, based on how your plug-in will be used.
    It is *highly* recommended you initiate the RIKLA process before doing any development as they have very strict guidelines on what they will and won't approve for a RIKLA key. Make sure you get everything approved by them before wasting time developing something they may turn down.

  • How to close infopath form through code?

    Hi All,
    How to close infopath form through code, thanks in advance!

    Hi Sam,
    Please check if the articles below can be help:
    http://www.bizsupportonline.net/browserforms/programmatically-submit-infopath-form-sharepoint-send-email-close-form.htm
    http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
    Regards,
    Rebecca Tu
    TechNet Community Support

Maybe you are looking for