I have a function that leverages the .NET messagebox.open which returns a result based on what clicked OK,Cancel,Yes,No etc. It works! I have the form that displays this message box when it first launches and this works.
What I'd like to do is conditionally execute an event say $buttonSubmit_Click if the response is the user clicked Yes button on the message box.
Here's what I have and what I tried that fails to work, I've tried other variations. I guess I am not sure how to execute it like this or if even possible without some special function or cmdlet. I looked at Register-ObjectEvent but it complained about EventName.
Short of re-creating the entire button click event with duplicated code, is there a way to call the button click event like this?
Code: Select all
$MainForm_Load={
$Answer = send-messagebox -message "Do you want to run the report?" -caption "Run report now?" -buttontype 4 -boxtype 32
if ($Answer -eq "Yes")
{
$buttonSubmit_click
}
}