Controls which resize themselves !

M

Martin

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!
 
M

Martin

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.clbCharacteristics);
this.slcMain.Panel2.Controls.Add(this.nudCapacity);
this.slcMain.Panel2.Controls.Add(this.nudMinOccupency);
this.slcMain.Panel2.Controls.Add(this.lblCharacteristics);
this.slcMain.Panel2.Controls.Add(this.txtNumber);
this.slcMain.Panel2.Controls.Add(this.lblRoomNumber);
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.lblMinOccupency);
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;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top