Solved

Help with placing focus on button in message box

Posted on 2012-03-20
5
198 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

14 Experts available now in Live!

Get 1:1 Help Now