IvanHowarth
asked on
Created a new form as a generic dialog result box, but 2 of the 3 buttons need to be clicked twice to work?
I have created a simple additional form (frmDialog) to my application. It contains 3 buttons and a label. The idea is to create a generic dialog result box to my main app.
Properties –
Form:
FormBorderStyle: FixedDialog
CancelButton: Button3
Button1:
DialogResult: “No”
Button2:
DialogResult: “Yes”
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
The method call used throughout my app supplying different strings in the new form:
ShowMyDialogForm("This Label Message.")
-------------------------- ---------- ---------- ---------- ---------- ---------- -----
The method to show frmDialog, display the message, and get the dialog result:
Private Sub ShowMyDialogForm (ByVal MessageToDisplay As String)
Dim dlg As New frmDialog
dlg.DisplayMessage(Message ToDisplay)
If dlg.ShowDialog = DialogResult.No Then
Debug.WriteLine("No Was Pressed")
ElseIf dlg.ShowDialog = DialogResult.Yes Then
Debug.WriteLine("Yes Was Pressed")
End If
End Sub
-------------------------- ---------- ---------- ---------- -------
The only method in the frmDialog to receive and display the message:
Public Sub DisplayMessage (ByVal Message As String)
Me.lblMessage.Text = Message
End Sub
-------------------------- ---------- ---------- ---------- --------
PROBLEM:
Click Button1 – OK but...
Both Button2 and Button3 need to be clicked twice before the respective Debug.WriteLine message/Cancel of frmDialog happens.
Please, why? And how to resolve?
A big thanks in advance.
Properties –
Form:
FormBorderStyle: FixedDialog
CancelButton: Button3
Button1:
DialogResult: “No”
Button2:
DialogResult: “Yes”
--------------------------
The method call used throughout my app supplying different strings in the new form:
ShowMyDialogForm("This Label Message.")
--------------------------
The method to show frmDialog, display the message, and get the dialog result:
Private Sub ShowMyDialogForm (ByVal MessageToDisplay As String)
Dim dlg As New frmDialog
dlg.DisplayMessage(Message
If dlg.ShowDialog = DialogResult.No Then
Debug.WriteLine("No Was Pressed")
ElseIf dlg.ShowDialog = DialogResult.Yes Then
Debug.WriteLine("Yes Was Pressed")
End If
End Sub
--------------------------
The only method in the frmDialog to receive and display the message:
Public Sub DisplayMessage (ByVal Message As String)
Me.lblMessage.Text = Message
End Sub
--------------------------
PROBLEM:
Click Button1 – OK but...
Both Button2 and Button3 need to be clicked twice before the respective Debug.WriteLine message/Cancel of frmDialog happens.
Please, why? And how to resolve?
A big thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER