473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

WinForm UserControl's controls runtime position diff. from design time position

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?
Jun 6 '06 #1
2 5024
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;
}
}
Jun 7 '06 #2
Thanks for doing that John, I appreciate it.
It may be something with the CAB framework?

Not sure, it's a hard one to debug as well ;0(
"John B" <jb******@yahoo.com> wrote in message
news:44**********@news.iprimus.com.au...
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;
}
}

Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tiago Barbutti | last post by:
I have a UserControl that execute methods in Load event, but it hapens in designMode and generate an error and the control disappear from the form. I read that i can use the DesignMode to kwnow...
7
by: Martin Schulze | last post by:
Hello, i tried to compose myself a custom usercontrol which is derieved from System.Windows.Forms.UserControl. It contains 2 comboboxes and one textbox (which are also custom controls, but...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
11
by: Crirus | last post by:
I need to derive the Windows.Forms.Control 2 times so I design a class like this Public Class BMControl Inherits System.Windows.Forms.UserControl Public Class MapControl Inherits BMControl
7
by: Alon | last post by:
Hi, I'm making my own control which holds some buttons ant textboxes and also has a panel control. in design time i want to drop another controls into the panel that is in my usercontrol. the...
5
by: Guillaume BRAUX | last post by:
Hello, What I want to do is to add a userControl to a form class witch is a different class from the one the button is generated. For example, I want to instanciate a label in "class1" and add...
2
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your...
3
by: Jose Fernandez | last post by:
Hello. I would like to know how could i get all the subscriptions that my form has with the events of their controls. For example. I have a form with a textbox, a button and a dropdown. I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.