0% found this document useful (0 votes)
32 views3 pages

Code

The document contains code for a FormMDI class that acts as a parent window for multiple child windows. It checks if a named child window exists before creating and showing it, to ensure only one instance exists. The FormVentana1 and FormVentana2 classes also follow this singleton pattern, only allowing one instance of each window type. On load, the FormMDI sets the username. Menu click events call the window classes to retrieve the single instances.

Uploaded by

Patrice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Code

The document contains code for a FormMDI class that acts as a parent window for multiple child windows. It checks if a named child window exists before creating and showing it, to ensure only one instance exists. The FormVentana1 and FormVentana2 classes also follow this singleton pattern, only allowing one instance of each window type. On load, the FormMDI sets the username. Menu click events call the window classes to retrieve the single instances.

Uploaded by

Patrice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

private void ventana3ToolStripMenuItem_Click(object sender, EventArgs e)

if (formIsOpen("FormVentana3") == false)

FormVentana3 frm = new FormVentana3();

frm.MdiParent = this;

frm.Show();

bool formIsOpen(string nombre_form)

foreach (var form_hijo in this.MdiChildren)

if (form_hijo.Text == nombre_form)

form_hijo.BringToFront();

return true;

return false;

return false;

public partial class FormMDI : Form

public FormMDI()

InitializeComponent();

}
private void ventana1ToolStripMenuItem_Click(object sender, EventArgs e)

FormVentana1 frm = FormVentana1.ventana_unica();

frm.MdiParent = this;

frm.Show();

frm.BringToFront();

private void ventana2ToolStripMenuItem_Click(object sender, EventArgs e)

FormVentana2 frm = FormVentana2.ventana_unica();

frm.MdiParent = this;

frm.Show();

frm.BringToFront();

private void FormMDI_Load(object sender, EventArgs e)

tssUsuario.Text = "WILLIAMS";

public partial class FormVentana1 : Form

private static FormVentana1 instancia= null;

public static FormVentana1 ventana_unica()

if (instancia ==null)

instancia = new FormVentana1();

return instancia;
}

return instancia;

public FormVentana1()

InitializeComponent();

public partial class FormVentana2 : Form

private static FormVentana2 instancia = null;

public static FormVentana2 ventana_unica()

if (instancia == null)

instancia = new FormVentana2();

return instancia;

return instancia;

public FormVentana2()

InitializeComponent();

You might also like