Solved

Help with placing focus on button in message box

Posted on 2012-03-20
5
195 Views
Last Modified: 2012-03-21
Hello,

I am using the code below  for users to decide Yes/No, is there a way to place the focus on No automatically and they would only need to press Enter or Click on it? Below is the code I am using.

Dim anadd As String
                    anadd = MsgBox("Are you sure you want to Add this record?", MsgBoxStyle.YesNo, "Warning before Attempting Adding record")
                    If anadd = MsgBoxResult.Yes Then
                     code is executed.....

I am using ASP.NET

Thanks,

Victor
0
Comment
Question by:vcharles
  • 3
5 Comments
 
LVL 2

Expert Comment

by:Sirjacksinurbox
ID: 37743148
I believe you are looking for MsgBoxDefaultButton. Then you have to play around with which button it might be. Should be button 2 though.

Here is an example:

MsgBox.Show(messageString, "Do you want to quit?", MsgBoxButtons.YesNo, MsgBoxIcon.Question, MsgBoxDefaultButton.Button2) 

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37743742
You will have to use Messagebox.Show as I believe msgbox does not accept this parameter
0
 
LVL 2

Accepted Solution

by:
Sirjacksinurbox earned 500 total points
ID: 37743837
Oops, CodeCruiser is right. I was getting the two mixed up. The link below should explain every clearly.

MessageBoxDefaultButton Enumeration

In my rush to answer the question,  I forgot that MsgBox and Messagebox.Show() are essentially the same thing, except that Messagebox.Show() allows for far more customization though.

Thank you for clarifying that CodeCruiser.
0
 

Author Closing Comment

by:vcharles
ID: 37750370
Thank You!
0
 
LVL 2

Expert Comment

by:Sirjacksinurbox
ID: 37750507
My pleasure. Thanks for asking!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

20 Experts available now in Live!

Get 1:1 Help Now