Reputation: 9
Hey there i like to use a nice designed Form with yes no Buttons to use it like the normal yes/no Messagebox. To be clear its not a Messagebox its a Form with a Background Picture and Label (for the Textbody) and 2 Buttons (yes / no).
But what must i do, that it opens the Form and send back the user´s choice that i can work with.
Messagetext = "This is the Text that is shown in the custBox"
Dim custBox As New custBox
CustBox.ShowDialog()
Select Case DialogResult
Case Windows.Forms.DialogResult.Yes
'code if clicked yes
Case Windows.Forms.DialogResult.No
'Code if clicked no
End Select
But i think it does not Work like this.
Upvotes: 0
Views: 300
Reputation: 39152
The DialogResult
is the RETURN value from ShowDialog()
, so you can do:
Dim cb As New custBox
Dim result As DialogResult = cb.ShowDialog()
Select Case result
Case Windows.Forms.DialogResult.Yes
'code if clicked yes
Case Windows.Forms.DialogResult.No
'Code if clicked no
End Select
Hopefully you're actually setting DialogResult
in your other form, when one of the buttons is clicked:
' ... in your "dialog" form, Yes/No Button Handler ...
Me.DialogResult = DialogResult.Yes ' or DialogResult.No
Upvotes: 1