Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a parent form and a "sign-in button". I coded the "sign-in button" so that if a field is left empty in the parent form, it shows message boxes for each field when clicked. e.g. "this field can't be empty"

but there's also a "second button" that takes me to a child form, to select some options.
Now, what code should I use, if I want the "sign-in button" to also show a message box for the "second button" if the "second button" is not clicked? letting the user know that they haven't visited the child form, to select options.


sign in button = signin_button
second button = visitor_meetingaimbutton

What I have tried:

private void signin_button_Click(object sender, EventArgs e)

{

if (visitor_meetingaimbutton = ??) - what should I use here?
{
MessageBox.Show("Meeting Aim Button Is Not Clicked");
}

}
Posted
Updated 11-Mar-22 7:17am
v2

Simple:
C#
private bool _secondButtonClicked = false;

private void second_button_Click(object sender, EventArgs e)
{
    _secondButtonClicked = true;
    ...
}

private void signin_button_Click(object sender, EventArgs e)
{
    ...
    if (!_secondButtonClicked)
    {
        MessageBox.Show("Meeting Aim Button Is Not Clicked");
        return;
    }
    ...
}
 
Share this answer
 
Comments
Maciej Los 11-Mar-22 13:18pm    
Fair enough!
5ed!
Two Otaku A 11-Mar-22 18:58pm    
Should I execute this in parent form or child form?
 
Share this answer
 

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



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