Solved

c# create dialog box

Posted on 2011-02-28
9
597 Views
Last Modified: 2013-12-17
Hi,
How can I choose dialogbox from toolbox?

Thanks,
JT
0
Comment
Question by:jtran007
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Which dialog box? Open, Save, Color, Folder and Font dialogs should all be available in the toolbox under the "Dialogs" heading.
0
 

Author Comment

by:jtran007
Comment Utility
Hi,

Customized dialog which just have label and one button.

Thannks,
JT
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 50 total points
Comment Utility
There is not preset dialogbox, you have to create your own. Theres a quick guide to creating your own dialog box here:

    http://msdn.microsoft.com/en-us/library/bb383855(v=vs.90).aspx
0
 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
If you are talking about MessageBox - you don't need to select it from the toolbox.  You just write in your code:

MessageBox.Show("your message", other options)

There is number of overloads for the static Show method. You may indicate buttons, icins, default button etc.

See:
http://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox.show(v=VS.80).aspx
0
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

 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
Just two examples (both show OK button:

            MessageBox.Show("Hello");
            MessageBox.Show("Hello","My Dialog Caption", MessageBoxButtons.OK);
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
Comment Utility
A dialogbox is just a form which is displayed modally.

MyForm frm = new MyForm();
frm.ShowDialog();   //Code halts here until the form is shown


OR
MyForm frm; //NOT local in the function
....
frm = new MyForm();
frm.Show();  //Code continues after here, even when form is shown
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 100 total points
Comment Utility
Just to clarify what AndyAinscow just told:

You may create your own dialog - just by creating a new form with a label and a button, as you wanted above.

To show the dialog you just call myCustomDialogForm.ShowDialog()

But! ShowDialog does not accept any results. It means you need to provide some custom code to set text on the label on the form. E.g., you may have a method like:

myCustomDialogForm.SetDialogMessage(string text){}


The you just call:

myCustomDialogForm.SetDialogMessage("Hello");
myCustomDialogForm.ShowDialog();
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Just seen a typo in my earlier comment
//Code halts here until the form is shown
should be
//Code halts here until the form is closed
0
 

Author Closing Comment

by:jtran007
Comment Utility
Thanks,
JT
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

10 Experts available now in Live!

Get 1:1 Help Now