Problems with anchoring RichEditBox on four sides if form is minimized

  • Thread starter Thread starter David
  • Start date Start date
D

David

I can whip up a demo if I have to, but basically if you create a form,
put a rich edit box (or text box) on it, set the rich edit box to
anchor on all four sides, then make the form initially Minimized, when
you Restore the form, the rich edit box gets resized to where it is
flush with the right and bottom edges of the form. If the form is not
initially Minimized, there is no problem.

Any explanations/workarounds? I'm new to Winforms after many years
with MFC and Win16 APIs, so I may be missing some obvious.
 
* David said:
I can whip up a demo if I have to, but basically if you create a form,
put a rich edit box (or text box) on it, set the rich edit box to
anchor on all four sides, then make the form initially Minimized, when
you Restore the form, the rich edit box gets resized to where it is
flush with the right and bottom edges of the form. If the form is not
initially Minimized, there is no problem.

What do you mean with "flush with the..."? I am not able to repro that
on a .NET 1.0 machine running Windows XP Professional.
 
What do you mean with "flush with the..."? I am not able to repro that
on a .NET 1.0 machine running Windows XP Professional.

My dev machine: Win XP Home, .NET 1.0, VS 2002

Here is an example. When the form is restored (un-minimized), the
rich text box has changed - the position within the form is the same,
but the size is bigger. The text box extends to the right and bottom
edges of the form, possible going underneath any buttons etc. on the
form. At least it does on my development machine - haven't tried it
anywhere else.

I worked around it by resizing the rich text box manually on Restore.
Very silly, but it works.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace RichTextTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
/// <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
InitializeComponent call
//
}

/// <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.richTextBox1 = new
System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Anchor =
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)
|
System.Windows.Forms.AnchorStyles.Left)
|
System.Windows.Forms.AnchorStyles.Right);
this.richTextBox1.Location = new
System.Drawing.Point(40, 40);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new
System.Drawing.Size(208, 176);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "richTextBox1";
//
// Form1
//
this.AutoScaleBaseSize = new
System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292,
266);
this.Controls.AddRange(new
System.Windows.Forms.Control[] {

this.richTextBox1});
this.Name = "Form1";
this.Text = "Form1";
this.WindowState =
System.Windows.Forms.FormWindowState.Minimized;
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
 
* David said:
My dev machine: Win XP Home, .NET 1.0, VS 2002

Here is an example. When the form is restored (un-minimized), the
rich text box has changed - the position within the form is the same,
but the size is bigger. The text box extends to the right and bottom
edges of the form, possible going underneath any buttons etc. on the
form. At least it does on my development machine - haven't tried it
anywhere else.

I worked around it by resizing the rich text box manually on Restore.
Very silly, but it works.

I am able to repro that on Windows XP Professional + .NET 1.0. For me,
this seems to be a bug. Would be interesting if it's fixed in .NET 1.1.
 
Back
Top