S
sirish csv via .NET 247
Hi,
I have an MDI application. Initially I open say 5 forms, theyposition themselves in a cascaded manner. When I close all ofthem and open another form it positions itself in the locationwhich would have come after the 5th form. It is as if the MDIparent is remembering the locations of the previously openedforms and positioning the new accordingly.
Ideally if all forms are closed and a new one is opened it shouldopen at the Top left corner of the MDI parent window.
Could someone tell me what can be done to ensure that forms opennormally one after the other(other than callingLayoutMDI.Cascade() as this would cascade even maximisedforms)So that the new form is consistent with the already openedforms if present.
This behavior can be observed in a simple example with 1 MDIparent and a child form opened from menu.Open 5 times and closeall forms and open again.
Thanks in advance.
Regards
Sirish
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem6;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponentcall
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(newSystem.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(newSystem.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem6});
this.menuItem1.Text = "Foems";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Forms1";
this.menuItem2.Click += newSystem.EventHandler(this.menuItem2_Click);
//
// menuItem6
//
this.menuItem6.Index = 1;
this.menuItem6.Text = "Form3";
this.menuItem6.Click += newSystem.EventHandler(this.menuItem6_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
Form2 frm;
private void menuItem2_Click(object sender, System.EventArgse)
{
frm= new Form2();
frm.MdiParent = this;
frm.Show();
}
private void menuItem6_Click(object sender, System.EventArgse)
{
Form3 frm1 = new Form3();
frm1.MdiParent = this;
frm1.Show();
}
}
I have an MDI application. Initially I open say 5 forms, theyposition themselves in a cascaded manner. When I close all ofthem and open another form it positions itself in the locationwhich would have come after the 5th form. It is as if the MDIparent is remembering the locations of the previously openedforms and positioning the new accordingly.
Ideally if all forms are closed and a new one is opened it shouldopen at the Top left corner of the MDI parent window.
Could someone tell me what can be done to ensure that forms opennormally one after the other(other than callingLayoutMDI.Cascade() as this would cascade even maximisedforms)So that the new form is consistent with the already openedforms if present.
This behavior can be observed in a simple example with 1 MDIparent and a child form opened from menu.Open 5 times and closeall forms and open again.
Thanks in advance.
Regards
Sirish
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem6;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponentcall
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(newSystem.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(newSystem.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem6});
this.menuItem1.Text = "Foems";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Forms1";
this.menuItem2.Click += newSystem.EventHandler(this.menuItem2_Click);
//
// menuItem6
//
this.menuItem6.Index = 1;
this.menuItem6.Text = "Form3";
this.menuItem6.Click += newSystem.EventHandler(this.menuItem6_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
Form2 frm;
private void menuItem2_Click(object sender, System.EventArgse)
{
frm= new Form2();
frm.MdiParent = this;
frm.Show();
}
private void menuItem6_Click(object sender, System.EventArgse)
{
Form3 frm1 = new Form3();
frm1.MdiParent = this;
frm1.Show();
}
}