Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with placing focus on button in message box

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
Avatar of Sirjacksinurbox
Sirjacksinurbox
Flag of United States of America image

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

Avatar of Nasir Razzaq
You will have to use Messagebox.Show as I believe msgbox does not accept this parameter
ASKER CERTIFIED SOLUTION
Avatar of Sirjacksinurbox
Sirjacksinurbox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Victor  Charles

ASKER

Thank You!
My pleasure. Thanks for asking!