Code:Public Class Info Sub New(ByVal promtmsg As String, ByVal btn1Text As String, ByVal btn2Text As String, ByVal showButtons() As Boolean) ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. ' set control values with the arguments that were passed to the constructor Me.LblIMessaggio.Text = promtmsg Me.BtnIOk.Text = btn1Text Me.BtnICancella.Text = btn2Text Me.BtnIOk.DialogResult = DialogResult.Yes Me.BtnICancella.DialogResult = DialogResult.No Me.AcceptButton = Me.BtnIOk Me.CancelButton = Me.BtnICancella Me.BtnIOk.Visible = showButtons(0) Me.BtnICancella.Visible = showButtons(1) Me.LblIMessaggio.Select() End Sub End ClassCode:'show dialog with 'Yes' button and 'Cancel' button Dim customMsgbox as New Info("Message", "Yes", "Cancel", New Boolean() {True, True}) If customMsgbox.ShowDialog() = DialogResult.Yes Then MsgBox("result = yes") Else MsgBox("result = cancelled") End If 'show dialog with just 'OK' button Dim customMsgbox as New Info("Message", "OK", "", New Boolean() {True, False}) If customMsgbox.ShowDialog() = DialogResult.Yes Then MsgBox("result = yes") Else MsgBox("result = cancelled") End If




Reply With Quote
