I have a child that pops up to display data.
but when the data changes a new form is created to display the new data.
I want to close the old form, so i don't end up with 5000 forms every time the data changes.
The reason a new form is created is so that in its name the data's ID can be shown.
My Code:
String Pass; // used to get value from class and pass it to next form.
public void ShowNewCompareDiff() //object sender, EventArgs e
{
FormCompareDiff childForm = new FormCompareDiff(Pass);
childForm.MdiParent = MdiParent;
childForm.Text = "Comepare difference ";
//childForm.Close(); //Not working
//childForm = null; //Not working
childForm.Show();
}
private void dataGridViewResult_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
CompareXML Com = new CompareXML();
Pass = Com.Compare(richTextBoxSQL.Text, richTextBoxPrevSQL.Text);
ShowNewCompareDiff();
}
Child form FormCompareDiff:
namespace AuditIT_1
{
public partial class FormCompareDiff : Form
{
String Passed;
public FormCompareDiff(String Pass)
{
Passed = Pass;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Location = new System.Drawing.Point(836, 0); // Form Shows next to FormSchemaSearch
InitializeComponent();
}
private void FormCompareDiff_Load(object sender, EventArgs e)
{
String Pass = Passed;
CompareXML Com = new CompareXML();
webBrowserDifferences.DocumentText = Com.ResultShow(Pass);
}
}
}