Solved

Dialog form closes when Cancel button is pressed

Posted on 2007-11-26
5
246 Views
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??

Thanks
Mike
0
Comment
Question by:michouis
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:jcoehoorn
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.
0
 

Author Comment

by:michouis
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.

Mike
0
 
LVL 18

Accepted Solution

by:
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.
0
 

Author Comment

by:michouis
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.

Mike
0
 

Author Closing Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is an explanation of a simple data model to help parse a JSON feed
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

828 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