Hi Gurus,
I've created through a new form a custom dialog box.
I've added the following code within the dialog box class:
And then I'm calling it where needed with the following code:Code:Private PromtMsg As String Sub New(ByVal promtmsg As String) ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. ' set global field with the argument that was passed to the constructor Me.PromtMsg = promtmsg End Sub Private Sub Info_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' set the msg label Me.LblIMessaggio.Text = Me.PromtMsg End Sub Private Sub BtnIOk_Click(sender As Object, e As EventArgs) Handles BtnIOk.Click ' user choosed yes - return DialogResult.Yes Me.DialogResult = DialogResult.Yes Me.Close() End Sub Private Sub BtnICancella_Click(sender As Object, e As EventArgs) Handles BtnICancella.Click ' user choosed no - DialogResult.no Me.DialogResult = DialogResult.No Me.Close() End Sub
Now, I would like at runtime to change the text of the two buttons initialized with the dialog box. I've tried changing them in the following way when I call the dialog box:Code:Dim customMsgbox = New Info("Message") If customMsgbox.ShowDialog() = DialogResult.Yes Then Me.Close() Else Me.Close() End If
but it retrieves me an error.Code:Dim customMsgbox = New Info("Message") Info.BtnIOk.Text = "Yes" If customMsgbox.ShowDialog() = DialogResult.Yes Then Me.Close() Else Me.Close() End If
Where should I have to change the code to allow me to change the text of the buttons and/or make one of them visible or not?
Thanks,
A.




Reply With Quote
