Solved

Dialog form closes when Cancel button is pressed

Posted on 2007-11-26
5
243 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now