MessageBox

  • Thread starter Thread starter Aris
  • Start date Start date
I think it returns a value based on the button, but not an event -
possibly you could inherit the class and alter it?

Paul
 
The MessageBox.Show method returns a value indicating what button they
pressed. Here is an example from one of my projects:

if (MessageBox.Show("Delete category ?", "Verify Delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) == DialogResult.Yes)

Or, you could assign the result to a variable such as:

DialogResult dr = MessageBox.Show("Blah blah blah", "Caption",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button3);

if (dr == DialogResult.Yes)
{
// do something
}


HTH,
Mark
 
hi

here how i use it:

Private Sub SubName()
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult

' Define message.
msg = "Put your message here"
style = MsgBoxStyle.DefaultButton1 Or
MsgBoxStyle.Question Or MsgBoxStyle.YesNo
' Define title.
title = "put your ActiveTitle here"
' Display message.
response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then
' User chose Yes do yes procedure.
else
' User chose No do no procedure.
End If
End Sub

this may help u
-- kurt --
 
Back
Top