Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
**
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.
------------------------------------------------------------------------

**
Posted
Comments
Sergey Alexandrovich Kryukov 15-May-15 2:56am    
There is no just "in VB.NET". Please, your application type, UI library/framework you are using.
—SA
Richard MacCutchan 15-May-15 3:14am    
Each form will need to open the messagebox when required, so when it returns "yes", the form can close itself.
Aruna Usitha 15-May-15 23:42pm    
my application type is .net framework i ithink :-). how do i add a custom buttons and background image to that popup message box.?

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 :
VB
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 :
VB
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
 
Share this answer
 
Comments
Aruna Usitha 16-May-15 23:43pm    
thanks man... ! :)
aleuznelav0526 26-Apr-20 8:45am    
This is so helpful. Thank you.
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
VB
(ByVal Message as String, ByVal MessageTitle as String) as String

on the Control's Load code part.
 
Share this answer
 
Comments
Aruna Usitha 18-May-15 10:35am    
thanks friend..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900