如何在vb.net中创建自定义消息框 [英] How to make a custom messagebox in vb.net

查看:121
本文介绍了如何在vb.net中创建自定义消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**


嘿,我刚刚创建了一个有6种形式的项目。我只想为这些表单添加自定义消息框。喜欢vb.net中的yes no type留言框









我的问题是如何知道打开msg框的表单,如果我在消息框中按是,如何关闭该表单。



对不起我的坏英语家伙。谢谢。

---------------------------------------- --------------------------------



**

**
hey, i just created a project that has 6 forms. i just want to add a custom message box to those forms. like the yes no type message box in vb.net




my question is how to know the form that opened the msg box and, if i press yes in the messagebox,how to close that form.

sorry for my bad english guys.! thanks.
------------------------------------------------------------------------

**

推荐答案

你可以建立一种对话框。

这是一个表格,可以根据需要创建,也可以满足你想要的设计。使用按钮,您可以在调用表单中设置DialogResult的值。



这可以像这样构建:



对话形式的脚本部分:

You could build up a kind of Dialog.
This is a Form, which is created as you want and which also content the design as you want. With the Buttons you set the value of DialogResult for which you ask in your calling Form.

This could be build up like this :

Script-Parts of the Dialog-Form :
Public Class Dialog_mySelection
    Inherits Form

    Private Sub Button_Abort_Click(sender As System.Object, e As System.EventArgs) Handles Button_Abort.Click

        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub Button_OK_Click(sender As System.Object, e As System.EventArgs) Handles Button_OK.Click

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

end class





脚本 - 调用表单中的部分:



Script-Parts inside the calling Form :

Dim myDialog As New Dialog_mySelection
myDialog.ShowDialog()

If myDialog.DialogResult = System.Windows.Forms.DialogResult.OK Then
    ' do what is nescessary to do
ElseIf myDialog.DialogResult = System.Windows.Forms.DialogResult.Cancel Then
    ' do what is nescessary to do
End If


您可以创建一个在VB.NET中使用自定义用户控件的高度自定义消息框。您只需要创建消息用户界面,并且必须创建

You can Create a highly Custom Message box using a Custom User Control in VB.NET. You just have to create the message user interface and have to create a
(ByVal Message as String, ByVal MessageTitle as String) as String




on the Control's Load code part.


这篇关于如何在vb.net中创建自定义消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆