473,396 Members | 1,995 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,396 software developers and data experts.

Controls which resize themselves !

Hi all !

I use Visual Studio .NET 2005 SP1 (+ Updates for Vista) on Windows
Vista. I have a strange problem in a WinForm application.

In a UserControl, which inherit another UserControl (simply contains a
SplitterPanel), I've added controls (most of them are TextBox with the
property Anchors set to Left and Right) to Panel2. All theses controls
fits in the UserControl and when I resize it, all the controls have
the correct behavior. My problem occurs when I compile the solution.
After a sucesseful compilation, if I re-open (of may refresh itself)
the Form Designer, all my controls are out of the UserControl!

Does someone have seen that before? Any ideas?

Thanks for your help!

Feb 5 '07 #1
1 2011
Here a piece of code that I use to reproduce the problem above. Could
someone give it a try ?

Thanks !

UserControlEx.cs

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

namespace Test
{
public partial class UserControlEx : UserControl
{
// Attributes
================================================== =======

// Properties
================================================== =======

// Constructor
================================================== ======
public UserControlEx()
{
InitializeComponent();
}

// Events
================================================== ===========
}
}

UserControlEx.designer.cs

namespace Test
{
partial class UserControlEx
{
/// <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.components = new System.ComponentModel.Container();
this.errorProvider = new
System.Windows.Forms.ErrorProvider(this.components );
this.slcMain = new System.Windows.Forms.SplitContainer();
((System.ComponentModel.ISupportInitialize)
(this.errorProvider)).BeginInit();
this.slcMain.Panel1.SuspendLayout();
this.slcMain.SuspendLayout();
this.SuspendLayout();
//
// errorProvider
//
this.errorProvider.BlinkStyle =
System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
this.errorProvider.ContainerControl = this;
//
// slcMain
//
this.slcMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.slcMain.FixedPanel =
System.Windows.Forms.FixedPanel.Panel1;
this.slcMain.Location = new System.Drawing.Point(0, 0);
this.slcMain.Margin = new System.Windows.Forms.Padding(0);
this.slcMain.Name = "slcMain";
//
// slcMain.Panel2
//
this.slcMain.Panel2.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.slcMain.Size = new System.Drawing.Size(540, 276);
this.slcMain.SplitterDistance = 175;
this.slcMain.TabIndex = 0;
this.slcMain.TabStop = false;
//
// UserControlEx
//
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.slcMain);
this.Font = new System.Drawing.Font("Segoe UI", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "UserControlEx";
this.Size = new System.Drawing.Size(540, 276);
((System.ComponentModel.ISupportInitialize)
(this.errorProvider)).EndInit();
this.slcMain.Panel1.ResumeLayout(false);
this.slcMain.Panel1.PerformLayout();
this.slcMain.ResumeLayout(false);
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.ErrorProvider errorProvider;
protected internal System.Windows.Forms.SplitContainer
slcMain;

}
}
RoomUC.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Test
{
public partial class RoomUC : UserControlEx
{
// Constructor
================================================== ======
public RoomUC()
{
InitializeComponent();
}

}
}
RoomUC.designer.cs

namespace Test
{
partial class RoomUC
{
/// <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.lblRoomNumber = new System.Windows.Forms.Label();
this.txtNumber = new System.Windows.Forms.TextBox();
this.lblRoomType = new System.Windows.Forms.Label();
this.ddlRoomType = new System.Windows.Forms.ComboBox();
this.lblCapacity = new System.Windows.Forms.Label();
this.lblMinOccupency = new System.Windows.Forms.Label();
this.nudMinOccupency = new
System.Windows.Forms.NumericUpDown();
this.nudCapacity = new
System.Windows.Forms.NumericUpDown();
this.lblCharacteristics = new
System.Windows.Forms.Label();
this.clbCharacteristics = new
System.Windows.Forms.CheckedListBox();
this.slcMain.Panel2.SuspendLayout();
this.slcMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)
(this.nudMinOccupency)).BeginInit();
((System.ComponentModel.ISupportInitialize)
(this.nudCapacity)).BeginInit();
this.SuspendLayout();
//
// slcMain
//
//
// slcMain.Panel2
//
this.slcMain.Panel2.Controls.Add(this.clbCharacter istics);
this.slcMain.Panel2.Controls.Add(this.nudCapacity) ;
this.slcMain.Panel2.Controls.Add(this.nudMinOccupe ncy);
this.slcMain.Panel2.Controls.Add(this.lblCharacter istics);
this.slcMain.Panel2.Controls.Add(this.txtNumber);
this.slcMain.Panel2.Controls.Add(this.lblRoomNumbe r);
this.slcMain.Panel2.Controls.Add(this.lblRoomType) ;
this.slcMain.Panel2.Controls.Add(this.ddlRoomType) ;
this.slcMain.Panel2.Controls.Add(this.lblCapacity) ;
this.slcMain.Panel2.Controls.Add(this.lblMinOccupe ncy);
this.slcMain.Size = new System.Drawing.Size(586, 350);
//
// lblRoomNumber
//
this.lblRoomNumber.AutoSize = true;
this.lblRoomNumber.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblRoomNumber.ImeMode =
System.Windows.Forms.ImeMode.NoControl;
this.lblRoomNumber.Location = new System.Drawing.Point(10,
21);
this.lblRoomNumber.Name = "lblRoomNumber";
this.lblRoomNumber.Size = new System.Drawing.Size(91, 13);
this.lblRoomNumber.TabIndex = 65;
this.lblRoomNumber.Text = "lblRoomNumber";
this.lblRoomNumber.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// txtNumber
//
this.txtNumber.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtNumber.Font = new System.Drawing.Font("Segoe UI",
8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtNumber.Location = new System.Drawing.Point(120,
18);
this.txtNumber.Name = "txtNumber";
this.txtNumber.Size = new System.Drawing.Size(284, 22);
this.txtNumber.TabIndex = 1;
//
// lblRoomType
//
this.lblRoomType.AutoSize = true;
this.lblRoomType.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblRoomType.ImeMode =
System.Windows.Forms.ImeMode.NoControl;
this.lblRoomType.Location = new System.Drawing.Point(10,
49);
this.lblRoomType.Name = "lblRoomType";
this.lblRoomType.Size = new System.Drawing.Size(73, 13);
this.lblRoomType.TabIndex = 67;
this.lblRoomType.Text = "lblRoomType";
this.lblRoomType.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// ddlRoomType
//
this.ddlRoomType.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ddlRoomType.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ddlRoomType.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ddlRoomType.FormattingEnabled = true;
this.ddlRoomType.Location = new System.Drawing.Point(120,
46);
this.ddlRoomType.Name = "ddlRoomType";
this.ddlRoomType.Size = new System.Drawing.Size(284, 21);
this.ddlRoomType.TabIndex = 2;
//
// lblCapacity
//
this.lblCapacity.AutoSize = true;
this.lblCapacity.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCapacity.ImeMode =
System.Windows.Forms.ImeMode.NoControl;
this.lblCapacity.Location = new System.Drawing.Point(10,
118);
this.lblCapacity.Name = "lblCapacity";
this.lblCapacity.Size = new System.Drawing.Size(63, 13);
this.lblCapacity.TabIndex = 71;
this.lblCapacity.Text = "lblCapacity";
this.lblCapacity.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// lblMinOccupency
//
this.lblMinOccupency.AutoSize = true;
this.lblMinOccupency.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMinOccupency.ImeMode =
System.Windows.Forms.ImeMode.NoControl;
this.lblMinOccupency.Location = new
System.Drawing.Point(10, 90);
this.lblMinOccupency.Name = "lblMinOccupency";
this.lblMinOccupency.Size = new System.Drawing.Size(96,
13);
this.lblMinOccupency.TabIndex = 70;
this.lblMinOccupency.Text = "lblMinOccupency";
this.lblMinOccupency.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// nudMinOccupency
//
this.nudMinOccupency.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.nudMinOccupency.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nudMinOccupency.Location = new
System.Drawing.Point(120, 88);
this.nudMinOccupency.Name = "nudMinOccupency";
this.nudMinOccupency.Size = new System.Drawing.Size(284,
22);
this.nudMinOccupency.TabIndex = 3;
//
// nudCapacity
//
this.nudCapacity.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.nudCapacity.Font = new System.Drawing.Font("Segoe
UI", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.nudCapacity.Location = new System.Drawing.Point(120,
116);
this.nudCapacity.Name = "nudCapacity";
this.nudCapacity.Size = new System.Drawing.Size(284, 22);
this.nudCapacity.TabIndex = 4;
//
// lblCharacteristics
//
this.lblCharacteristics.AutoSize = true;
this.lblCharacteristics.Font = new
System.Drawing.Font("Segoe UI", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.lblCharacteristics.ImeMode =
System.Windows.Forms.ImeMode.NoControl;
this.lblCharacteristics.Location = new
System.Drawing.Point(10, 159);
this.lblCharacteristics.Name = "lblCharacteristics";
this.lblCharacteristics.Size = new System.Drawing.Size(94,
13);
this.lblCharacteristics.TabIndex = 76;
this.lblCharacteristics.Text = "lblCharacteristics";
this.lblCharacteristics.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;
//
// clbCharacteristics
//
this.clbCharacteristics.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.clbCharacteristics.FormattingEnabled = true;
this.clbCharacteristics.Location = new
System.Drawing.Point(120, 159);
this.clbCharacteristics.Name = "clbCharacteristics";
this.clbCharacteristics.Size = new
System.Drawing.Size(284, 89);
this.clbCharacteristics.TabIndex = 77;
//
// RoomUC
//
this.Name = "RoomUC";
this.Size = new System.Drawing.Size(586, 350);
this.slcMain.Panel2.ResumeLayout(false);
this.slcMain.Panel2.PerformLayout();
this.slcMain.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)
(this.nudMinOccupency)).EndInit();
((System.ComponentModel.ISupportInitialize)
(this.nudCapacity)).EndInit();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Label lblRoomNumber;

private System.Windows.Forms.TextBox txtNumber;
private System.Windows.Forms.Label lblRoomType;
private System.Windows.Forms.ComboBox ddlRoomType;

private System.Windows.Forms.Label lblCapacity;
private System.Windows.Forms.Label lblMinOccupency;
private System.Windows.Forms.NumericUpDown nudMinOccupency;
private System.Windows.Forms.NumericUpDown nudCapacity;

private System.Windows.Forms.Label lblCharacteristics;
private System.Windows.Forms.CheckedListBox
clbCharacteristics;
}
}


Feb 6 '07 #2

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

Similar topics

1
by: Yongseung Kim | last post by:
Hi, I would like to describe as clear as I can(sorry my english is quite limited) 1. I made a project with vb.net on english XP Pro (The project has a winform with several general controls...
0
by: nospam | last post by:
Does anyone know what would cause controls on a C# WinForm to resize when the form is saved. Buttons, panels, textboxes are all resizing themselves whenever I do a save for some inexplicable reason?
2
by: ichor | last post by:
hi i am developing a c# app and i want that when i size the form the controls should also be automatically sized. thanx
1
by: rudjohn | last post by:
I've been tasked with the not-enviable job of creating an application with multiple, semi-customizable templates. My basic concept, thus far, has been a combination of Master Pages (for layout) and...
2
by: james | last post by:
As part of my app I am programatically adding some Label controls to a form at runtime. The code for these is part of a function that is overrriding the Paint event of the form. The other stuff...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: LonelyRanger | last post by:
Hi Everyone, Thanks for your time. My question is based on VB.NET, pictureboxes and a scrollablecontrol. I have several pictureboxes inside a scrollable control. The scrollablecontrol is...
14
by: zubair1 | last post by:
Hello, I am want to Resize my form and form controls based on the users resolution. For example :- i am making this application in 1024x768. it obviously works and looks well too me but when my...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.