With win forms
i am trying to have an extension method to open OR show the existing instance of the form , if its already open.
but if the form is already open, it's not being presented at the front and activated,
However if its not working new instance is being presented correctly
what im doing wrong ?
i am trying to have an extension method to open OR show the existing instance of the form , if its already open.
but if the form is already open, it's not being presented at the front and activated,
However if its not working new instance is being presented correctly
what im doing wrong ?
vb.net Code:
public static void OpenOrShowFrom(this Form f) { Boolean IsOpen = false; foreach (Form frm in Application.OpenForms) { IsOpen = frm.Name == f.Name; if (IsOpen) { break; } } // If for is already open just bring it to front & Activate // TODO: If form is already open , it's not being bring to front & activated ? if (IsOpen) { f.Activate(); f.WindowState = FormWindowState.Normal; f.BringToFront(); } else // Other wise open new instance of the form { f.Show(); } }