Click here to Skip to main content
15,890,357 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all, I make a modalness custom messagebox, that let me click on the calling form. Now on this custom, I have created, two buttons and a dialog result, I also created a public class and Inherits the form where these buttons are. In another form I created a value as a new Dialog_Selection then I edited code where if statement is. Now all of this are inside a for-next loop that will go with the next index only if the yes button it's pressed. I will paste the code for more clarification.
This is what I have in the form4 (the calling one for the custom message box)
Dim mydialog As New Form5.Dialog_mySelection
Form5.Show()
If mydialog.DialogResult = System.Windows.Forms.DialogResult.Yes Then tempArray(counter) = "[img" & "(" & ComboBox2.Text.ToString & ") ]" & vbCrLf & "[img" & "(" & tempArray(counter) & ") ]" & "(" & tempArray2(counter) & ")"
  Else
  If mydialog.DialogResult = System.Windows.Forms.DialogResult.Yes Then
  End If

While this is what I have on the Form5 (the custom message box)
Public Class Form5

Public Class Dialog_mySelection
Inherits Form5

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       DialogResult = System.Windows.Forms.DialogResult.Yes
        End Sub

        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            DialogResult = System.Windows.Forms.DialogResult.No
        End Sub
    End Class
End Class


What I have tried:

The code above, also now the calling window can be clicked like I wished to achieve, but now the problem is that the windows appear without problem with yes no button, but when clicked on a yes or no, nothing happening. Is there some error in this code? Thanks for the advice.
Posted
Updated 1-Jan-22 10:32am
v3

1 solution

As I said when you asked your first question on this subject, calling Show returns immediately - that's the whole point.

What you need to do is either raise an event when the button is clicked in the new form (and handle it in the "parent") or handle the FormClosing event for the new form in the "parent" so you know when the user is finished with it.

See here: Transferring information between two forms, Part 2: Child to Parent[^]
The code is in C# rather than VB, but it's pretty simple and an online converter can help you if you can't work it out: Code Converter C# to VB and VB to C# – Telerik[^]
 
Share this answer
 

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

  Print Answers RSS


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