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()
{
InitializeComponent();
}
}
}
//.Designer
namespace Foo
{
partial class ResizeControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer 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.Dispose();
}
base.Dispose(disposing);
}
#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 InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(13, 14);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(13, 40);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// ResizeControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Name = "ResizeControl";
this.Size = new System.Drawing.Size(127, 73);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
}
}