当我们点击MDIParent1

时间:2016-12-02 12:30:06

标签: vb.net

当我们点击MDIParent1的菜单栏上的退出应用程序标签时,应该显示消息框是否如果我单击是然后应用程序关闭,如果我单击否则应用程序应该不关闭并且表单仍然活着打开< / p>

Private Sub ExitApplicaionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitApplicaionToolStripMenuItem.Click

    MessageBox.Show("Are you sure you want to exit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

    If MsgBoxResult.Yes Then

        Application.Exit()

    Else

        'Focus remain on targeted form which is open that time

    End If

End Sub

1 个答案:

答案 0 :(得分:3)

show-method returns the dialogresult:

If MessageBox.Show("Are you sure you want to exit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = MsgBoxResult.Yes Then
    Application.Exit()
End If