473,549 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5044
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;
}
}
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()
{
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;
}
}

Jun 7 '06 #3

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

Similar topics

1
4923
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 when my control is in design or Runtime mode, it´s work, but when this usercontrol is put in another usercontrol the DesignMode property always...
7
12492
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 directly derived from the .net classes ComboBox and TextBox) I did the custom control in the visual studio .net designer in which i
1
4007
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 same way a menu does. To do this my control needs to get notified when the user tried to click off of it. The Leave and LostFocus events of the...
4
3099
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 UserControls into the PlaceHolder's child control collection depending upon which of the three radio buttons is selected. Each of the three UserControls have...
11
5271
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
3791
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 problem is that the added controls are added to the usercontrol and not to the panel... 10X,
5
1990
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 it ("show it") on a WinForm situated in "class2" (without having to add code to class2 !) The problem is that I need to instanciate "class2" from...
2
2815
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 toolbar exists in. I'm writing my own usercontrol which contains various different controls (e.g. Panel, Button). I would like these controls to be...
3
2448
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 create a subscription to the Click event of the Button and another to the SelectedIndexChanged del dropDown.
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.