[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Seyting a MessageBoxButtons.YesNo default to No

Posted on 2006-07-09
3
Medium Priority
?
420 Views
Last Modified: 2012-08-14
Hi,

How do I set the default button to No?  Please don't tell me I can't use a stock message box for that?

Bob
0
Comment
Question by:ba272
  • 2
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17069945
Hi ba272,

You need to use the MessageBoxDefaultButton arguments. Something like this:

        Dim Message As String = "You did not enter a server name. Cancel this operation?"
        Dim Caption As String = "No Server Name Specified"
        Dim Buttons As Integer = MessageBoxButtons.YesNo

        Dim Result As DialogResult

        'Displays a MessageBox using the Question icon and specifying the No button as the default.

        Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)




Cheers!
0
 

Author Comment

by:ba272
ID: 17069950
No speak.  I C#, can you?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 17069961
It's almost just a matter of ;

        string message = "You did not enter a server name. Cancel this operation?";
        string caption = "No Server Name Specified";
        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
        DialogResult result;

        // Displays the MessageBox.

        result = MessageBox.Show(this, message, caption, buttons,
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

Ref: http://msdn2.microsoft.com/en-us/library/system.windows.forms.messageboxdefaultbutton.aspx
0

Featured Post

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!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

873 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