Solved

c# create dialog box

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

Thanks,
JT
0
Comment
Question by:jtran007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35001402
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
ID: 35001491
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
ID: 35001685
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 35001745
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
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 35001796
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
ID: 35001991
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 30

Accepted Solution

by:
anarki_jimbel earned 100 total points
ID: 35003557
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
ID: 35004468
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
ID: 35014511
Thanks,
JT
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 365: Assigning MailboxPlan to a mailbox 8 71
.Net remove carriage returns, line feeds and tabbs 5 36
sql connection error null reference exception 9 29
Example code 13 42
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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