vb.net - How to make an single instance form -
I have a mdicontainer form that has summons forms. When a user clicks on the menu for that form again, my problem is, it is also another example of this.
What I did but this is a public class announcement with a public variable earlier: Boolean isFormOneOpen = false. So every time the formOne opens, this is the first time that I declare the global variable some time ago, it is wrong, if it is, an instance of an object of formOne and then checks to show it. Otherwise, do not do anything very stable, imagine if I have many variations, I have to declare a variable for each form to check if it is already open. Can you provide me a solution for this? Perhaps a method that accepts a form? Or any more clever way to do this.
You do not need a variable, you can see if the form is already open Gaya. For example:
Private sub-btnViewChild_Click (ByVal, in the form of this System.Object, byVal e System.EventArgs) manages btnViewChild.Click for each child in Me.MdiChildren Typeof baby form2 is child then. WindowState = FormWindowState.Normal child.Focus () Exit from sub-end if new form 2 FRM as next DEM FM MDPER = m frm.Show () and sub
VB.NET-focused solution:
Private sub by btnViewChild_Click (ByVal Sender by System.Object, System ByVal as EventArgs and) btnViewChild handles. Click Form2.MdiParent = Form 2.
Comments
Post a Comment