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

Designer corrupts my control positions. (With reproduction steps; please help)

I have a large form, with several hundred controls. When I open it in
the designer, the designer resizes the form, but does not adjust the
size of anchored controls in containers, thus corrupting them. With a
great deal of effort, I've managed to remove every control that isn't
needed to reproduce the problem.

To reproduce the problem, do the following:
1) Create a project with the code below. Note that tabGeneral is 690
pixels high, and it contains a grid that is 652 pixel high, and
anchored top and bottom.
2) Open the form in the designer.
3) In the code, note that the designer has adjusted the height of the
tab to 669 (apparently to accommodate the MainMenu), but has not
adjusted the height of the anchored grid.

How can I fix or work around this problem?

using System;
using System.Windows.Forms;

namespace WindowsApplication1
{
public class Form1 : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new Form1());
}
public Form1()
{
InitializeComponent();
tabSettings.SelectedTab = tabGeneral;
}
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.menuMain = new
System.Windows.Forms.MainMenu(this.components);
this.miFile = new System.Windows.Forms.MenuItem();
this.miExit = new System.Windows.Forms.MenuItem();
this.tabGeneral = new System.Windows.Forms.TabPage();
this.gridGeneral = new
System.Windows.Forms.DataGridView();
this.tabSettings = new System.Windows.Forms.TabControl();
this.tabGeneral.SuspendLayout();
((System.ComponentModel.ISupportInitialize)
(this.gridGeneral)).BeginInit();
this.tabSettings.SuspendLayout();
this.SuspendLayout();
//
// menuMain
//
this.menuMain.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.miFile});
//
// miFile
//
this.miFile.Index = 0;
this.miFile.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {
this.miExit});
this.miFile.Text = "&File";
//
// miExit
//
this.miExit.Index = 0;
this.miExit.Text = "E&xit";
//
// tabGeneral
//
this.tabGeneral.Controls.Add(this.gridGeneral);
this.tabGeneral.Location = new System.Drawing.Point(4,
22);
this.tabGeneral.Name = "tabGeneral";
this.tabGeneral.Padding = new
System.Windows.Forms.Padding(3);
this.tabGeneral.Size = new System.Drawing.Size(910, 690);
this.tabGeneral.TabIndex = 1;
this.tabGeneral.Text = "General";
this.tabGeneral.UseVisualStyleBackColor = true;
//
// gridGeneral
//
this.gridGeneral.Anchor =
((System.Windows.Forms.AnchorStyles)
((((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridGeneral.Location = new System.Drawing.Point(6,
6);
this.gridGeneral.Name = "gridGeneral";
this.gridGeneral.Size = new System.Drawing.Size(898, 652);
this.gridGeneral.TabIndex = 0;
//
// tabSettings
//
this.tabSettings.Anchor =
((System.Windows.Forms.AnchorStyles)
((((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabSettings.Controls.Add(this.tabGeneral);
this.tabSettings.Location = new System.Drawing.Point(12,
12);
this.tabSettings.Name = "tabSettings";
this.tabSettings.SelectedIndex = 0;
this.tabSettings.Size = new System.Drawing.Size(918, 695);
this.tabSettings.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,
13F);
this.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(942, 732);
this.Controls.Add(this.tabSettings);
this.Menu = this.menuMain;
this.Name = "Form1";
this.Text = "Product Settings";
this.tabGeneral.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)
(this.gridGeneral)).EndInit();
this.tabSettings.ResumeLayout(false);
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.MainMenu menuMain;
private System.Windows.Forms.MenuItem miFile;
private System.Windows.Forms.MenuItem miExit;
private System.Windows.Forms.TabPage tabGeneral;
private System.Windows.Forms.DataGridView gridGeneral;
private System.Windows.Forms.TabControl tabSettings;
}
}

Jun 22 '07 #1
0 1302

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

Similar topics

28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
5
by: Markus Wildgruber | last post by:
Hi! We create an inherited user control and add it to a form. When we successfully compile the project and switch to the designer of the form again, the control disappears and we get 2 error...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
1
by: johndow | last post by:
The project I am getting into is to provide a way to dynamically customize the layout of of a web form. For example, a survey page may contains many fields. We want to allow our customers to move...
11
by: PAul Maskens | last post by:
The form designer adds unnecessary code to the section when using a subclassed control. I've reproduced this in VS.NET 2002 and VS.NET 2003 so it's pretty fundamental. Outline steps: Create a...
1
by: Lucien Dol | last post by:
Hi all, Can someone help me with this, please? I've got a user control that (amongst other controls) contains a textbox. The textbox has its Anchor property set to "Left, Top, Right", meaning...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
6
by: Deano | last post by:
Every once in a while I modify one particular form (could be anything from adding code to tweaking properties as far as I can see) and upon loading I get; "You can't assign a value to this...
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: 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.