Dialog form closes when Cancel button is pressed

Posted on 2007-11-26
Last Modified: 2010-04-23
I am displaying a modal form which a user can edit information in text boxes. If they click the Cancel button I am doing a ds.tables(0).rejectchanges which appears to be firing a close-form event... why???
Also, it does not reset the value in the binded text box to the original value like other forms do. Why? I do a ds.tables(0).rows(0).canceledit and then ds.tables(0).rejectchanges and would expect the original value to re-appear in the text box but it does not.... why??

Question by:michouis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 18

Expert Comment

ID: 20351992
When you look at the properties for the form you'll see a property named "CancelButton" that accepts a Button.  If you click the button set there then the form will close and return DialogResult.Cancel.  Clear that property and the form won't close anymore.

Author Comment

ID: 20352122
I do not have the Cancel button set as the CancelButton property for the form. I have a totally different button called ExitButton that is set to the CancelButton property of the form... so please try again.

LVL 18

Accepted Solution

jcoehoorn earned 500 total points
ID: 20352233
A dataset has absolutely nothing to do with a form staying open or closed.  

The AcceptButton property is similar to CancelButton, but returns DialogResult.Ok instead of DialogResult.Cancel.  The only way the form will close is if you click one of those buttons, click the X in the top right of the form, or call the form's .Close(), .Dispose(), or .Hide() methods.  

It might be possible for another program to somehow slip a WM_CLOSE or WM_TERMINATE message into the window's event loop, but the .Net framework will only do that via the methods I just described.

Author Comment

ID: 20352819
ok., I changed the DialogResult property to None on all 3 buttons, (Update, Cancel, Exit) and it now behaves normally.

As for the rejectchanges not resetting the value to original value... I removed the binding format of "C"urrency from these text boxes and it also now behaves normally, just no currency formatting.

In all I am fine now. Thanks for your help any ways.


Author Closing Comment

ID: 31411024
Gave me some clues which helped in resolution.

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question