Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey there fellow coders,

I'm stuck. I need to pass a value from one form to another and then back again. Here's the story: (most of the code works)
Pseudo:
If Window1 Checkbox1 is checked pop messagebox - this works
If messagebox result = OK, pass value to Window2 Checkbox2 - this works
If SAVE on Window2 do the database write thing... and leave checkbox1 on Window1 checked - this work
If messagebox result = CANCEL, make Checkbox2 NOT checked and also make Checkbox1 on Windows1 NOT checked.

Where I'm struggling is the "reloading" or "refreshing" the Window1 after the cancel. I don't want to lose the data on Window1, I just want to "reload/reinitialize/refresh/whatever" Checkbox1 with IsChecked=false.

I can supply code, but I think What I have is wrong so let me share what I have that passes the correct value to Window2

C#
public void Handle(CheckBox checkbox)
{
   var flag = checkbox.IsChecked != null && checkbox.IsChecked.Value;

   switch (flag)
   {
      case true;
         var results = MessagebBox.Show("Message","Title",MessageBoxButton.OKCancel,MessageBoxImage.Question);
         if (result == MesaageBoxResult.OK)
         {
            var ap = new Window2();
            if (checkbox.IsChecked != null) ap.C = checkbox.IsChecked.Value;
            // C = public bool C; on Window2
            ap.Show();
         }
         else
         }
            checkbox.IsChecked = true;
         }
         break;
    }
}


I guess I can't figure out how to set C = false or not checked and pass that back into focus. Thoughts?
Posted

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