G
Guest
I have the exact same problem that's described in the post I'm attaching.
This post ws placed by Dave Leach on Mon, Apr 17 2006 4:30 pm because . If
anyone knows the solutions just let me know.
POST:
I am developing a Windows Forms application using Visual Studio 2003 and C#.
The application uses the MDI style. The problem I have encountered appears
to be a bug in .NET Framework 1.1.
The problem is that controls in a panel on an MDI child form become
unreachable (no longer visible) if a combination of scroll, form hide, form
resize, and form show operations are performed.
The steps to create the problem are as follows:
- Show the child form in its normal location and size on the main form.
- Significantly resize the child form, causing scroll bars to appear.
- Scroll the child form visible area to the lower-right corner, causing
contained controls in the upper-left to no longer be visible.
- Hide the child form ( Form.Hide() ).
- Programmatically resize the child form to its original size.
- Show the the child form ( Form.Show() ).
- Now the only visible controls are the lower-right ones that were visible
after the above scroll operation and they are located in the upper-left
corner of the form.
I have recreated the problem with a very simple MDI example. I created a
main form set be an MDI container and added a single child form. The child
form contains a single panel which contains four Label controls and four
TextBox controls. The child form has the AutoScroll property set to true.
The panel has its AutoScroll property set to true and its Dock property set
to DockStyle.Fill. The Labels and TextBoxes are spread out on the panel and
form to the four corners. I added a couple of menu items to the main form to
hide and show the child form.
The sample code is provided below.
Is this a known problem?
Is there a work-around?
Thanks,
Dave
==== Sample Code ====
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Main
{
public class MdiMain : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem mniTopFile;
private System.Windows.Forms.MenuItem mniExit;
private System.Windows.Forms.MenuItem mniTopActions;
private System.Windows.Forms.MenuItem mniOpen;
private System.Windows.Forms.MenuItem mniClose;
private System.Windows.Forms.MenuItem mniResize;
private ChildForm child;
public MdiMain()
{
InitializeComponent();
child = new ChildForm();
child.MdiParent = this;
child.Location = new Point( 20, 10 );
child.Show();
}
private void InitializeComponent()
{
this.mainMenu = new System.Windows.Forms.MainMenu();
this.mniTopFile = new System.Windows.Forms.MenuItem();
this.mniExit = new System.Windows.Forms.MenuItem();
this.mniTopActions = new System.Windows.Forms.MenuItem();
this.mniOpen = new System.Windows.Forms.MenuItem();
this.mniClose = new System.Windows.Forms.MenuItem();
this.mniResize = new System.Windows.Forms.MenuItem();
//
// mainMenu
//
this.mainMenu.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniTopFile,
this.mniTopActions});
//
// mniTopFile
//
this.mniTopFile.Index = 0;
this.mniTopFile.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniExit});
this.mniTopFile.Text = "File";
//
// mniExit
//
this.mniExit.Index = 0;
this.mniExit.Text = "Exit";
this.mniExit.Click += new System.EventHandler(this.mniExit_Click);
//
// mniTopActions
//
this.mniTopActions.Index = 1;
this.mniTopActions.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniOpen,
this.mniClose,
this.mniResize});
this.mniTopActions.Text = "Actions";
//
// mniOpen
//
this.mniOpen.Index = 0;
this.mniOpen.Text = "Open";
this.mniOpen.Click += new System.EventHandler(this.mniOpen_Click);
//
// mniClose
//
this.mniClose.Index = 1;
this.mniClose.Text = "Close";
this.mniClose.Click += new System.EventHandler(this.mniClose_Click);
//
// mniResize
//
this.mniResize.Index = 2;
this.mniResize.Text = "Resize";
this.mniResize.Click += new
System.EventHandler(this.mniResize_Click);
//
// MdiMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(592, 473);
this.IsMdiContainer = true;
this.Menu = this.mainMenu;
this.Name = "MdiMain";
this.Text = "MdiMain";
}
[STAThread]
static void Main()
{
Application.Run(new MdiMain());
}
private void mniOpen_Click(object sender, System.EventArgs e)
{
this.child.Location = new Point( 20, 10 );
this.child.Size = new Size( 350, 400 );
this.child.Show();
}
private void mniClose_Click(object sender, System.EventArgs e)
{
this.child.Hide();
}
private void mniResize_Click(object sender, System.EventArgs e)
{
this.child.Size = new Size( 350, 400 );
}
private void mniExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
} // class MdiMain
public class ChildForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel pnlMain;
private System.Windows.Forms.Label labelTopLeft;
private System.Windows.Forms.Label labelBottomLeft;
private System.Windows.Forms.Label labelTopRight;
private System.Windows.Forms.Label labelBottomRight;
private System.Windows.Forms.TextBox textBoxTopLeft;
private System.Windows.Forms.TextBox textBoxBottomLeft;
private System.Windows.Forms.TextBox textBoxTopRight;
private System.Windows.Forms.TextBox textBoxBottomRight;
public ChildForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.pnlMain = new System.Windows.Forms.Panel();
this.textBoxBottomRight = new System.Windows.Forms.TextBox();
this.textBoxTopRight = new System.Windows.Forms.TextBox();
this.textBoxBottomLeft = new System.Windows.Forms.TextBox();
this.textBoxTopLeft = new System.Windows.Forms.TextBox();
this.labelBottomRight = new System.Windows.Forms.Label();
this.labelTopRight = new System.Windows.Forms.Label();
this.labelBottomLeft = new System.Windows.Forms.Label();
this.labelTopLeft = new System.Windows.Forms.Label();
this.pnlMain.SuspendLayout();
this.SuspendLayout();
//
// pnlMain
//
this.pnlMain.AutoScroll = true;
this.pnlMain.Controls.Add(this.textBoxBottomRight) ;
this.pnlMain.Controls.Add(this.textBoxTopRight);
this.pnlMain.Controls.Add(this.textBoxBottomLeft);
this.pnlMain.Controls.Add(this.textBoxTopLeft);
this.pnlMain.Controls.Add(this.labelBottomRight);
this.pnlMain.Controls.Add(this.labelTopRight);
this.pnlMain.Controls.Add(this.labelBottomLeft);
this.pnlMain.Controls.Add(this.labelTopLeft);
this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlMain.Location = new System.Drawing.Point(0, 0);
this.pnlMain.Name = "pnlMain";
this.pnlMain.Size = new System.Drawing.Size(342, 373);
this.pnlMain.TabIndex = 0;
//
// textBoxBottomRight
//
this.textBoxBottomRight.Location = new System.Drawing.Point(270,
180);
this.textBoxBottomRight.Name = "textBoxBottomRight";
this.textBoxBottomRight.Size = new System.Drawing.Size(60, 20);
this.textBoxBottomRight.TabIndex = 7;
this.textBoxBottomRight.Text = "Text Four";
//
// textBoxTopRight
//
this.textBoxTopRight.Location = new System.Drawing.Point(270, 20);
this.textBoxTopRight.Name = "textBoxTopRight";
this.textBoxTopRight.Size = new System.Drawing.Size(60, 20);
this.textBoxTopRight.TabIndex = 6;
this.textBoxTopRight.Text = "Text Three";
//
// textBoxBottomLeft
//
this.textBoxBottomLeft.Location = new System.Drawing.Point(100, 180);
this.textBoxBottomLeft.Name = "textBoxBottomLeft";
this.textBoxBottomLeft.Size = new System.Drawing.Size(60, 20);
this.textBoxBottomLeft.TabIndex = 3;
this.textBoxBottomLeft.Text = "Text Two";
//
// textBoxTopLeft
//
this.textBoxTopLeft.Location = new System.Drawing.Point(100, 20);
this.textBoxTopLeft.Name = "textBoxTopLeft";
this.textBoxTopLeft.Size = new System.Drawing.Size(60, 20);
this.textBoxTopLeft.TabIndex = 2;
this.textBoxTopLeft.Text = "Text One";
//
// labelBottomRight
//
this.labelBottomRight.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBottomRight.Location = new System.Drawing.Point(180, 180);
this.labelBottomRight.Name = "labelBottomRight";
this.labelBottomRight.Size = new System.Drawing.Size(80, 24);
this.labelBottomRight.TabIndex = 5;
this.labelBottomRight.Text = "Label Four";
this.labelBottomRight.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelTopRight
//
this.labelTopRight.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelTopRight.Location = new System.Drawing.Point(180, 20);
this.labelTopRight.Name = "labelTopRight";
this.labelTopRight.Size = new System.Drawing.Size(80, 24);
this.labelTopRight.TabIndex = 4;
this.labelTopRight.Text = "Label Three";
this.labelTopRight.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelBottomLeft
//
this.labelBottomLeft.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBottomLeft.Location = new System.Drawing.Point(10, 180);
this.labelBottomLeft.Name = "labelBottomLeft";
this.labelBottomLeft.Size = new System.Drawing.Size(80, 24);
this.labelBottomLeft.TabIndex = 1;
this.labelBottomLeft.Text = "Label Two";
this.labelBottomLeft.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelTopLeft
//
this.labelTopLeft.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelTopLeft.Location = new System.Drawing.Point(10, 20);
this.labelTopLeft.Name = "labelTopLeft";
this.labelTopLeft.Size = new System.Drawing.Size(80, 24);
this.labelTopLeft.TabIndex = 0;
this.labelTopLeft.Text = "Label One";
this.labelTopLeft.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// ChildForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(342, 373);
this.Controls.Add(this.pnlMain);
this.Name = "ChildForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "ChildForm";
this.pnlMain.ResumeLayout(false);
this.ResumeLayout(false);
}
} // class ChildForm
}
Regards,
Javier Vazquez
This post ws placed by Dave Leach on Mon, Apr 17 2006 4:30 pm because . If
anyone knows the solutions just let me know.
POST:
I am developing a Windows Forms application using Visual Studio 2003 and C#.
The application uses the MDI style. The problem I have encountered appears
to be a bug in .NET Framework 1.1.
The problem is that controls in a panel on an MDI child form become
unreachable (no longer visible) if a combination of scroll, form hide, form
resize, and form show operations are performed.
The steps to create the problem are as follows:
- Show the child form in its normal location and size on the main form.
- Significantly resize the child form, causing scroll bars to appear.
- Scroll the child form visible area to the lower-right corner, causing
contained controls in the upper-left to no longer be visible.
- Hide the child form ( Form.Hide() ).
- Programmatically resize the child form to its original size.
- Show the the child form ( Form.Show() ).
- Now the only visible controls are the lower-right ones that were visible
after the above scroll operation and they are located in the upper-left
corner of the form.
I have recreated the problem with a very simple MDI example. I created a
main form set be an MDI container and added a single child form. The child
form contains a single panel which contains four Label controls and four
TextBox controls. The child form has the AutoScroll property set to true.
The panel has its AutoScroll property set to true and its Dock property set
to DockStyle.Fill. The Labels and TextBoxes are spread out on the panel and
form to the four corners. I added a couple of menu items to the main form to
hide and show the child form.
The sample code is provided below.
Is this a known problem?
Is there a work-around?
Thanks,
Dave
==== Sample Code ====
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Main
{
public class MdiMain : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem mniTopFile;
private System.Windows.Forms.MenuItem mniExit;
private System.Windows.Forms.MenuItem mniTopActions;
private System.Windows.Forms.MenuItem mniOpen;
private System.Windows.Forms.MenuItem mniClose;
private System.Windows.Forms.MenuItem mniResize;
private ChildForm child;
public MdiMain()
{
InitializeComponent();
child = new ChildForm();
child.MdiParent = this;
child.Location = new Point( 20, 10 );
child.Show();
}
private void InitializeComponent()
{
this.mainMenu = new System.Windows.Forms.MainMenu();
this.mniTopFile = new System.Windows.Forms.MenuItem();
this.mniExit = new System.Windows.Forms.MenuItem();
this.mniTopActions = new System.Windows.Forms.MenuItem();
this.mniOpen = new System.Windows.Forms.MenuItem();
this.mniClose = new System.Windows.Forms.MenuItem();
this.mniResize = new System.Windows.Forms.MenuItem();
//
// mainMenu
//
this.mainMenu.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniTopFile,
this.mniTopActions});
//
// mniTopFile
//
this.mniTopFile.Index = 0;
this.mniTopFile.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniExit});
this.mniTopFile.Text = "File";
//
// mniExit
//
this.mniExit.Index = 0;
this.mniExit.Text = "Exit";
this.mniExit.Click += new System.EventHandler(this.mniExit_Click);
//
// mniTopActions
//
this.mniTopActions.Index = 1;
this.mniTopActions.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.mniOpen,
this.mniClose,
this.mniResize});
this.mniTopActions.Text = "Actions";
//
// mniOpen
//
this.mniOpen.Index = 0;
this.mniOpen.Text = "Open";
this.mniOpen.Click += new System.EventHandler(this.mniOpen_Click);
//
// mniClose
//
this.mniClose.Index = 1;
this.mniClose.Text = "Close";
this.mniClose.Click += new System.EventHandler(this.mniClose_Click);
//
// mniResize
//
this.mniResize.Index = 2;
this.mniResize.Text = "Resize";
this.mniResize.Click += new
System.EventHandler(this.mniResize_Click);
//
// MdiMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(592, 473);
this.IsMdiContainer = true;
this.Menu = this.mainMenu;
this.Name = "MdiMain";
this.Text = "MdiMain";
}
[STAThread]
static void Main()
{
Application.Run(new MdiMain());
}
private void mniOpen_Click(object sender, System.EventArgs e)
{
this.child.Location = new Point( 20, 10 );
this.child.Size = new Size( 350, 400 );
this.child.Show();
}
private void mniClose_Click(object sender, System.EventArgs e)
{
this.child.Hide();
}
private void mniResize_Click(object sender, System.EventArgs e)
{
this.child.Size = new Size( 350, 400 );
}
private void mniExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
} // class MdiMain
public class ChildForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel pnlMain;
private System.Windows.Forms.Label labelTopLeft;
private System.Windows.Forms.Label labelBottomLeft;
private System.Windows.Forms.Label labelTopRight;
private System.Windows.Forms.Label labelBottomRight;
private System.Windows.Forms.TextBox textBoxTopLeft;
private System.Windows.Forms.TextBox textBoxBottomLeft;
private System.Windows.Forms.TextBox textBoxTopRight;
private System.Windows.Forms.TextBox textBoxBottomRight;
public ChildForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.pnlMain = new System.Windows.Forms.Panel();
this.textBoxBottomRight = new System.Windows.Forms.TextBox();
this.textBoxTopRight = new System.Windows.Forms.TextBox();
this.textBoxBottomLeft = new System.Windows.Forms.TextBox();
this.textBoxTopLeft = new System.Windows.Forms.TextBox();
this.labelBottomRight = new System.Windows.Forms.Label();
this.labelTopRight = new System.Windows.Forms.Label();
this.labelBottomLeft = new System.Windows.Forms.Label();
this.labelTopLeft = new System.Windows.Forms.Label();
this.pnlMain.SuspendLayout();
this.SuspendLayout();
//
// pnlMain
//
this.pnlMain.AutoScroll = true;
this.pnlMain.Controls.Add(this.textBoxBottomRight) ;
this.pnlMain.Controls.Add(this.textBoxTopRight);
this.pnlMain.Controls.Add(this.textBoxBottomLeft);
this.pnlMain.Controls.Add(this.textBoxTopLeft);
this.pnlMain.Controls.Add(this.labelBottomRight);
this.pnlMain.Controls.Add(this.labelTopRight);
this.pnlMain.Controls.Add(this.labelBottomLeft);
this.pnlMain.Controls.Add(this.labelTopLeft);
this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlMain.Location = new System.Drawing.Point(0, 0);
this.pnlMain.Name = "pnlMain";
this.pnlMain.Size = new System.Drawing.Size(342, 373);
this.pnlMain.TabIndex = 0;
//
// textBoxBottomRight
//
this.textBoxBottomRight.Location = new System.Drawing.Point(270,
180);
this.textBoxBottomRight.Name = "textBoxBottomRight";
this.textBoxBottomRight.Size = new System.Drawing.Size(60, 20);
this.textBoxBottomRight.TabIndex = 7;
this.textBoxBottomRight.Text = "Text Four";
//
// textBoxTopRight
//
this.textBoxTopRight.Location = new System.Drawing.Point(270, 20);
this.textBoxTopRight.Name = "textBoxTopRight";
this.textBoxTopRight.Size = new System.Drawing.Size(60, 20);
this.textBoxTopRight.TabIndex = 6;
this.textBoxTopRight.Text = "Text Three";
//
// textBoxBottomLeft
//
this.textBoxBottomLeft.Location = new System.Drawing.Point(100, 180);
this.textBoxBottomLeft.Name = "textBoxBottomLeft";
this.textBoxBottomLeft.Size = new System.Drawing.Size(60, 20);
this.textBoxBottomLeft.TabIndex = 3;
this.textBoxBottomLeft.Text = "Text Two";
//
// textBoxTopLeft
//
this.textBoxTopLeft.Location = new System.Drawing.Point(100, 20);
this.textBoxTopLeft.Name = "textBoxTopLeft";
this.textBoxTopLeft.Size = new System.Drawing.Size(60, 20);
this.textBoxTopLeft.TabIndex = 2;
this.textBoxTopLeft.Text = "Text One";
//
// labelBottomRight
//
this.labelBottomRight.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBottomRight.Location = new System.Drawing.Point(180, 180);
this.labelBottomRight.Name = "labelBottomRight";
this.labelBottomRight.Size = new System.Drawing.Size(80, 24);
this.labelBottomRight.TabIndex = 5;
this.labelBottomRight.Text = "Label Four";
this.labelBottomRight.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelTopRight
//
this.labelTopRight.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelTopRight.Location = new System.Drawing.Point(180, 20);
this.labelTopRight.Name = "labelTopRight";
this.labelTopRight.Size = new System.Drawing.Size(80, 24);
this.labelTopRight.TabIndex = 4;
this.labelTopRight.Text = "Label Three";
this.labelTopRight.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelBottomLeft
//
this.labelBottomLeft.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBottomLeft.Location = new System.Drawing.Point(10, 180);
this.labelBottomLeft.Name = "labelBottomLeft";
this.labelBottomLeft.Size = new System.Drawing.Size(80, 24);
this.labelBottomLeft.TabIndex = 1;
this.labelBottomLeft.Text = "Label Two";
this.labelBottomLeft.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// labelTopLeft
//
this.labelTopLeft.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.labelTopLeft.Location = new System.Drawing.Point(10, 20);
this.labelTopLeft.Name = "labelTopLeft";
this.labelTopLeft.Size = new System.Drawing.Size(80, 24);
this.labelTopLeft.TabIndex = 0;
this.labelTopLeft.Text = "Label One";
this.labelTopLeft.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// ChildForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(342, 373);
this.Controls.Add(this.pnlMain);
this.Name = "ChildForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "ChildForm";
this.pnlMain.ResumeLayout(false);
this.ResumeLayout(false);
}
} // class ChildForm
}
Regards,
Javier Vazquez