Solved

Default button from Msgbox

Posted on 2004-10-20
1
252 Views
Last Modified: 2012-05-05
How can I set the default button from Msgbox ?

Thanks !
0
Comment
Question by:vbhaha
[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
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 12366130
Using MsgBox you can't.  It is a carry over from VB6.

You can specify the default button using the .Net version, MessageBox():

Overloads Public Shared Function Show( _
   ByVal text As String, _
   ByVal caption As String, _
   ByVal buttons As MessageBoxButtons, _
   ByVal icon As MessageBoxIcon, _
   ByVal defaultButton As MessageBoxDefaultButton _
) As DialogResult

For example:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("Are you sure?", "Delete all files", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
            ' delete files...
        End If
    End Sub

This displays a YesNo dialog with No as the default.

~IM
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import a excel sheet in a grid 2 43
Read oracle BLOB in vb.net 2 23
Disable the weekends on datepicker control 6 51
vb.net code 9 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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