Register  |  Login



Question

Status: Closed Points: 75 Time: 06:13 - Mar 01, 2007  

dustPuppy

How can I show an alert in a windows forms application?

I'm programming my first windows .net application in C# and I need to show an error alert, similar to the alert in javascript in web applications.
I tried with ShowDialog, but it requires a windows form to show as far as i understand. Isn't there something more simple, like the web counterpart?

Answer Discussion
Answer Summaries

 

Q&A System for Websites and Corporate Collaboration

Advertisement

  • Generates significant organic traffic for websites
  • Saves companies money, resources, and time

rcastagna

Date:: Mar 01, 2007

Time:: 07:59

Hey, dust...venturing out past the web world, I see! (It's a dark, scary world out there...turn back while there's still hope!)

Seriously, though...if you're looking for something like the javascript alert() or confirm() take a look at MessageBox.Show in your windows form.

Here's some sample code that will give you a messagebox with your typical OK/Cancel buttons like a javascript confirm():

DialogResult dlgRes = null
dlgRes = MessageBox.Show(
 "Are you sure you want to close without saving the document",
 "Confirm Document Close",
MessageBoxButtons.YesNoCancel,
 MessageBoxIcon.Question);

if(dlgRes == DialogResult.Yes) { Application.Exit(); }

There are other ENUM combinations available for the buttons in MessageBoxButtons so you should be able to tailor and trap the user's response as necessary.

I hope this helps...

Ric

dustPuppy

Date:: Mar 01, 2007

Time:: 08:02

great, exactly what I was looking for...
your the man, ric :)

rcastagna

Date:: Mar 02, 2007

Time:: 14:04

Hey, dust...just wanted to see if that worked for you and to gently remind you to award the points, if appropriate. :)

Ric

dustPuppy

Date:: Mar 23, 2007

Time:: 15:11

sorry about that Ric, i forgot to close the question.
here are the points...

Prajith

Date:: Jul 24, 2007

Time:: 13:05

Hi,
Using MessageBox itself you can show alert. You can even have custom images on your MessageBox

MessageBox.Show("Your Alert Message", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

Question Answered

This question has been closed, and points have been rewarded to the following experts:

rcastagna: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for the Summary Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No summaries have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top .net Experts

View More

Rank

Expert

Points

1.

PeterNZ

885

2.

nidhi

515

3.

rcastagna

488

4.

multani.sarbjit

200

5.

dustPuppy

75

6.

Sergio Costa

50

7.

Zoush

50

8.

manohar.patil

30

9.

xarcus

25

10.

prashanth.guru

20

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es