Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

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?

Categories

Answer Discussion
Tutorials

 

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);

roshantechline

Date:: Feb 08, 2010

Time:: 02:30

Sir
i am student,i am doing work a project,sir my problem how automatic timing alert in winform,plz help me
Thanks

siddhuchauhan30

Date:: Oct 16, 2010

Time:: 06:53

You can use NotifyIcon fro Showing Alert in Window Application.

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 a Tutorial in the Tutorial 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 tutorials 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 Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

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