473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Form.ShowDialog(), how to disable exiting on button click

(using Windows CE, C#)
I have a form that is called with frmname.ShowDialog(), and it of
course has an OK button which returns a DialogResult.OK.
How can I disable closing the form when I want to (specifically, when
I get an exception from a database operation). In that case, instead
of exiting the form I want to display a MessageBox, and continue form.

Thanks in advance

Alberto

Sep 22 '07 #1
1 2673
Hi alberto,

I guess you'd like something liker that ?

private void MyModalForm_Closing(object sender, CancelEventArgs e)
{
try
{
throw new Exception("oh rage, oh désespoir, oh
vieillesse ennemie ...");
}
catch (Exception ex)
{
MessageBox.Show("An error occured : " + ex.Message);
e.Cancel = true;
}
}
}

alberto wrote :
(using Windows CE, C#)
I have a form that is called with frmname.ShowDialog(), and it of
course has an OK button which returns a DialogResult.OK.
How can I disable closing the form when I want to (specifically, when
I get an exception from a database operation). In that case, instead
of exiting the form I want to display a MessageBox, and continue form.

Thanks in advance

Alberto
Sep 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen Haeney via .NET 247 | last post by:
Rather than developing an application with numerous frames andhiding/showing them as required, I decided to investigatestarting my Winform application via a class and using delegatesto decide which...
6
by: Mathieu Chavoutier | last post by:
Hi. I want to create a kind of configuration window. So, I have a main window, and when I click on a button, it opens a new form. But, because it is a configuration window, I would like that...
1
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a...
5
by: Ivan | last post by:
I am used to VB6 and am not sure how to do this in Vstudio .NET. I have a main form which calls other forms. I want to disable that main form while other ones are called. I tried hiding it and...
2
by: Max | last post by:
I've done quiet a bit of VB programming using versions 5 and 6. Now I finally got my hands on .NET and all I can say is "I am soooo lost". Would appreciate it if you guys could help me out with...
0
by: Ahmad Jalil Qarshi | last post by:
Hi! I have a problem while developing some webpages.The Problem is that:- How We Can Disable The Controls Of One Web Form From Other Web Form In Asp.net? Explanation:- There Should Be Two...
3
by: Tony Johansson | last post by:
Hello! I have a modal dialog lets call it TestDialog that is shown by using method showDialog(). This TestDialog has three controls it's one richtextbox and two buttons. The buttons is one Ok...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
5
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.