Visual Studio中的msgbox按钮类型

时间:2013-02-28 13:12:16

标签: vb.net visual-studio-2010 visual-studio

如何设置一个包含“ok”和“cancel”等按钮的消息框?我们也可以为按钮命名我们自己的名字吗?我们可以为这些按钮编写源代码,例如

ok.click, form1.show() and if cancel.click form5.show()
msgbox()

4 个答案:

答案 0 :(得分:0)

您可以使用MessageBoxButtons枚举在消息框上指定不同类型的按钮,并在单击按钮后使用DialogResult为每种类型的消息框按钮指定不同的操作。 或create your own MessageBox

答案 1 :(得分:0)

试试这个:

MessageBox.Show("put your text here", "here the title of you message", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand)

在第二个逗号[,]之后你可以把按钮类型放在最后,你可以把你认为最适合你的消息框的图标

问候

答案 2 :(得分:0)

这应该有效:

If (MsgBox("Your Text", MsgBoxStyle.OkCancel, "MessageBox Title") = MsgBoxResult.Ok) Then
        Form1.Show()
    Else
        form5.show()
    End If

答案 3 :(得分:0)

这是一个简单的消息框:

If MessageBox.Show("some msg", "caption", MessageBoxButtons.OKCancel) = DialogResult.Cancel Then
    ' you cancel it, so i will show another message box
EndIf