Hey everyone. I have a crazy problem that occurs after I close a form. Here's are the steps.
1. Open MainWindow.xaml
2. Open NewWindow1.xaml from MainWindow.xaml
3. Connect NewWindow1.xaml to SQL as a new customer or edit customer.
4. Close NewWindow1.xaml when done.
5. Open NewWindow1.xaml again
6. If the user presses "Retrieve" without providing a customer ID, the form returns the value from the last search...
How do I close a form and destroy all prior used values so that this doesn't occur any more?
Additional hints:
I use a double click event inside a List View to show the forms. Inside the event, I use a switch (case form 1 open form 1, case form2 open form2, etc.)
<pre lang="c#">
private void ListViewItem_PharmDoubleClick(object sender, MouseButtonEventArgs e)
{
var obj = (DependencyObject) e.OriginalSource;
while (obj != null && !Equals(obj, PharmacyLv))
{
if (obj.GetType() == typeof (ListViewItem))
{
var Item = (ListViewItem) sender;
var pf = (PharmForms) Item.Content;
var msgTitle = "Form Request " + pf.FormNamePharm;
var msgCaption = "You requested to open " + pf.FormCodePharm + " - " + pf.FormNamePharm +
". \nPress OK to continue or CANCEL to select again.";
var result = MessageBox.Show(msgCaption, msgTitle, MessageBoxButton.OKCancel,
MessageBoxImage.Question);
switch (result)
{
case MessageBoxResult.OK:
switch (pf.FormCodePharm)
{
case "Form1":
OpenForm1();
break;
case "Form2":
OpenForm2();
break;
case "Form3":
OpenForm3();
break;
case "Form4":
OpenForm4();
break;
case "":
break;
}
break;
case MessageBoxResult.No:
break;
}
break;
}
obj = VisualTreeHelper.GetParent(obj);
}
}
</pre>