Steve wrote:
This is a weird one.
I have a series of "SmartParts " which are CAB (Composite Application Block)
Views which are finally just UserControls (99% of the time)
Anyway, I layout my UserControl in the VS2005 designer, but at runtime, the
controls are in different locations and different sizes. I have been able
to restore their sizes by putting a hack together that will set their sizes
to the correct values in the UserControl's Resize EventHandler, but like I
said, it's a hack and is a pain.
I can reproduce this with a brand new UserControl with two simple TextEdit
controls and no other code. In the designer I place them right next to each
other, at runtime they are farther apart. Anchoring isn't the issue, they
aren't docked, just floating.
Any ideas?
I tried it with two textboxes placed on a usercontrol and at design and
run time they do not move.
There must be something different with your control or install of vs2005.
My control follows
--
JB
//ResizeControl
using System;
using System.Windows. Forms;
namespace Foo
{
public partial class ResizeControl : UserControl
{
public ResizeControl()
{
InitializeCompo nent();
}
}
}
//.Designer
namespace Foo
{
partial class ResizeControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.textBox1 = new System.Windows. Forms.TextBox() ;
this.textBox2 = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// textBox1
//
this.textBox1.L ocation = new System.Drawing. Point(13, 14);
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(100, 20);
this.textBox1.T abIndex = 0;
//
// textBox2
//
this.textBox2.L ocation = new System.Drawing. Point(13, 40);
this.textBox2.N ame = "textBox2";
this.textBox2.S ize = new System.Drawing. Size(100, 20);
this.textBox2.T abIndex = 1;
//
// ResizeControl
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.Controls.A dd(this.textBox 2);
this.Controls.A dd(this.textBox 1);
this.Name = "ResizeControl" ;
this.Size = new System.Drawing. Size(127, 73);
this.ResumeLayo ut(false);
this.PerformLay out();
}
#endregion
private System.Windows. Forms.TextBox textBox1;
private System.Windows. Forms.TextBox textBox2;
}
}