简体   繁体   English

Visual Studio中的msgbox按钮类型

[英]msgbox button type in visual studio

How to set a message box which has buttons like "ok" and "cancel"? 如何设置一个带有“确定”和“取消”之类的按钮的消息框? Also can we name our own names for the buttons? 我们还可以为按钮命名吗? And can we write source codes for those buttons, like 我们可以为这些按钮编写源代码吗?

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

You could use MessageBoxButtons enum to specify different kinds of buttons on messagebox and use DialogResult after the button is clicked to specify different actions for each type of messagebox button. 您可以使用MessageBoxButtons枚举指定消息框上的不同类型的按钮,并在单击按钮后为每种类型的消息框按钮指定不同的操作,然后使用DialogResult Or create your own MessageBox 创建自己的MessageBox

Try this: 尝试这个:

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

after the second comma [,] you can put the type of buttons and at the last you can put the icon you think it will best suit your message box 在第二个逗号[,]之后,您可以放置​​按钮的类型,最后可以放置您认为最适合您的消息框的图标

regards 问候

This should work: 这应该工作:

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

This is a simple message box: 这是一个简单的消息框:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM