rwheeler23
asked on
Opening forms using C#. Is one way better than another?
What is the difference between opening a form this way:
...and opening it this way?
I am still learning C# and I see multiple ways to open forms. Is there a proper way or is one way better under one set of circumstances and another way better under another set of circumstances?
if (ViewGLDistributionsForm == null)
{
ViewGLDistributionsForm = new frmViewGLDistributions();
}
else
{
if (ViewGLDistributionsForm.Created == false)
{
ViewGLDistributionsForm = new frmViewGLDistributions();
}
}
ViewGLDistributionsForm.Show();
ViewGLDistributionsForm.Activate();
...and opening it this way?
using (frmLookupBatchIDs LookupBatchIDsForm = new frmLookupBatchIDs(batchNumber))
{
if (LookupBatchIDsForm.ShowDialog(this) == DialogResult.OK)
{
LookupBatchIDsForm.Show();
LookupBatchIDsForm.Activate();
LookupBatchIDsForm.Focus();
batchNumber = LookupBatchIDsForm.CellValue;
}
}
I am still learning C# and I see multiple ways to open forms. Is there a proper way or is one way better under one set of circumstances and another way better under another set of circumstances?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.