Solved

c# create dialog box

Posted on 2011-02-28
9
598 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
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
 
LVL 29

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 29

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 29

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

18 Experts available now in Live!

Get 1:1 Help Now