in my form when i check both checkboxes i would like for a messagebox to displayed. both checkboxes linked to one messagebox. i have tried different messagebox functionality but all end up displaying the messagebox when one check box is marked.
if (e.KeyCode == Keys.Q)
checkBox1.Checked = !checkBox1.Checked;
if (e.KeyCode == Keys.A)
checkBox2.Checked = !checkBox2.Checked;
MessageBox.Show("task completed", "form1");
This worked for me.
private void cbox2_Checked(object sender, RoutedEventArgs e)
{
if (cbox1.IsChecked == true && cbox2.IsChecked == true)
{
MessageBox.Show("task completed", "form1");
}
}
private void cbox1_Checked(object sender, RoutedEventArgs e)
{
if (cbox1.IsChecked == true && cbox2.IsChecked == true)
{
MessageBox.Show("task completed", "form1");
}
}
Set the if
statements at both Checked
events of the check boxes
Not very elegant, but working.