What has happened to my controls?

  • Thread starter Thread starter Paul Hemans
  • Start date Start date
P

Paul Hemans

Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can
no longer see any of my controls, on any of the pages, or even the
tabControl itself. They still exist because the various objects are
available in the properties interface. If I select one I can see all the
properties but the control doesn't show in the design area.
When I run the application the form appears blank. Here are the properties
on the tabControl that I would consider relevant (evidently I am missing
something):
Enabled True
ItemSize 420, 180
Location 0,0
MaximumSize 600, 800
Size 471, 800
Visible True

My conclusion would be that something has gone wrong in Form1.Designer.cs
but I haven't touched it (I swear I never did). The code inside
InitializeComponent() looks ok.

Any ideas would be appreciated.
 
My conclusion would be that something has gone wrong in Form1.Designer.cs
but I haven't touched it (I swear I never did). The code inside
InitializeComponent() looks ok.

This happened to me with VS2005 and the Tab Control - closing and
re-opening VS usually fixed it. I haven't seen it in VS2008 (yet!).
 
Had my first VS2008 Winforms designer disaster the other day. It just
started complaining that the .resx file for one of my forms was corrupt.
Looking at the error you could see a bunch of text in nice columns up until
the problem point where there were five lines of complete garbage. The
program would then not compile.

Luckily I didn't have much in there and copying the .cs and the .Designer.cs
into a new form solved it.
 
Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can
no longer see any of my controls, on any of the pages, or even the
tabControl itself. They still exist because the various objects are
available in the properties interface. If I select one I can see all the
properties but the control doesn't show in the design area.
When I run the application the form appears blank. Here are the properties
on the tabControl that I would consider relevant (evidently I am missing
something):
Enabled True
ItemSize 420, 180
Location 0,0
MaximumSize 600, 800
Size 471, 800
Visible True

My conclusion would be that something has gone wrong in Form1.Designer.cs
but I haven't touched it (I swear I never did). The code inside
InitializeComponent() looks ok.

Any ideas would be appreciated.
Hi
Delete your obj directory and rebuild. It's VS's scratch pad. Have you
noticed that intellisense is also playing up?
Mark
 
Hi Mark,
I deleted the properties and the obj directories and it didn't help.
Am I correct in assuming that nothing I have done within my code (Form1.cs)
should affect Form1.Designer.cs? The fact that the objects appear in the
properties window suggests that the form designer is reading the
initializeComponent() method. It is just the layout that is malfunctioning.

In case it helps, this is the code in the initializeComponent() from
Form1.Designer.cs...
private void InitializeComponent()

{

this.StatusLabel = new System.Windows.Forms.Label();

this.chkLogging = new System.Windows.Forms.CheckBox();

this.tabControl = new System.Windows.Forms.TabControl();

this.controlPage = new System.Windows.Forms.TabPage();

this.StopButton = new System.Windows.Forms.Button();

this.StartButton = new System.Windows.Forms.Button();

this.dbPage = new System.Windows.Forms.TabPage();

this.checkLogging = new System.Windows.Forms.CheckBox();

this.label1 = new System.Windows.Forms.Label();

this.listenPort = new System.Windows.Forms.TextBox();

this.submitButton = new System.Windows.Forms.Button();

this.reloadButton = new System.Windows.Forms.Button();

this.dataGridView = new System.Windows.Forms.DataGridView();

this.serviceController = new System.ServiceProcess.ServiceController();

this.tabControl.SuspendLayout();

this.controlPage.SuspendLayout();

this.dbPage.SuspendLayout();

((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();

this.SuspendLayout();

//

// StatusLabel

//

this.StatusLabel.AutoSize = true;

this.StatusLabel.Location = new System.Drawing.Point(30, 17);

this.StatusLabel.Name = "StatusLabel";

this.StatusLabel.Size = new System.Drawing.Size(73, 13);

this.StatusLabel.TabIndex = 3;

this.StatusLabel.Text = "IP address is :";

//

// chkLogging

//

this.chkLogging.AutoSize = true;

this.chkLogging.Location = new System.Drawing.Point(17, 13);

this.chkLogging.Name = "chkLogging";

this.chkLogging.Size = new System.Drawing.Size(68, 17);

this.chkLogging.TabIndex = 4;

this.chkLogging.Text = "Log data";

this.chkLogging.UseVisualStyleBackColor = true;

//

// tabControl

//

this.tabControl.Controls.Add(this.controlPage);

this.tabControl.Controls.Add(this.dbPage);

this.tabControl.Location = new System.Drawing.Point(12, 12);

this.tabControl.Name = "tabControl";

this.tabControl.SelectedIndex = 0;

this.tabControl.Size = new System.Drawing.Size(471, 510);

this.tabControl.TabIndex = 5;

//

// controlPage

//

this.controlPage.Controls.Add(this.StopButton);

this.controlPage.Controls.Add(this.StartButton);

this.controlPage.Controls.Add(this.StatusLabel);

this.controlPage.Location = new System.Drawing.Point(4, 22);

this.controlPage.Name = "controlPage";

this.controlPage.Padding = new System.Windows.Forms.Padding(3);

this.controlPage.Size = new System.Drawing.Size(463, 484);

this.controlPage.TabIndex = 0;

this.controlPage.Text = "Status";

this.controlPage.UseVisualStyleBackColor = true;

//

// StopButton

//

this.StopButton.Location = new System.Drawing.Point(301, 66);

this.StopButton.Name = "StopButton";

this.StopButton.Size = new System.Drawing.Size(75, 23);

this.StopButton.TabIndex = 5;

this.StopButton.Text = "Stop";

this.StopButton.UseVisualStyleBackColor = true;

//

// StartButton

//

this.StartButton.Location = new System.Drawing.Point(33, 62);

this.StartButton.Name = "StartButton";

this.StartButton.Size = new System.Drawing.Size(75, 23);

this.StartButton.TabIndex = 4;

this.StartButton.Text = "Start";

this.StartButton.UseVisualStyleBackColor = true;

//

// dbPage

//

this.dbPage.Controls.Add(this.checkLogging);

this.dbPage.Controls.Add(this.label1);

this.dbPage.Controls.Add(this.listenPort);

this.dbPage.Controls.Add(this.submitButton);

this.dbPage.Controls.Add(this.reloadButton);

this.dbPage.Controls.Add(this.dataGridView);

this.dbPage.Controls.Add(this.chkLogging);

this.dbPage.Location = new System.Drawing.Point(4, 22);

this.dbPage.Name = "dbPage";

this.dbPage.Padding = new System.Windows.Forms.Padding(3);

this.dbPage.Size = new System.Drawing.Size(463, 484);

this.dbPage.TabIndex = 1;

this.dbPage.Text = "Connections";

this.dbPage.UseVisualStyleBackColor = true;

//

// checkLogging

//

this.checkLogging.AutoSize = true;

this.checkLogging.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((byte)(0)));

this.checkLogging.Location = new System.Drawing.Point(228, 56);

this.checkLogging.Name = "checkLogging";

this.checkLogging.Size = new System.Drawing.Size(71, 17);

this.checkLogging.TabIndex = 11;

this.checkLogging.Text = "Logging";

this.checkLogging.UseVisualStyleBackColor = true;

//

// label1

//

this.label1.AutoSize = true;

this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((byte)(0)));

this.label1.Location = new System.Drawing.Point(18, 55);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(42, 13);

this.label1.TabIndex = 9;

this.label1.Text = "Port #";

//

// listenPort

//

this.listenPort.Location = new System.Drawing.Point(69, 52);

this.listenPort.Name = "listenPort";

this.listenPort.Size = new System.Drawing.Size(46, 20);

this.listenPort.TabIndex = 8;

//

// submitButton

//

this.submitButton.Location = new System.Drawing.Point(363, 13);

this.submitButton.Name = "submitButton";

this.submitButton.Size = new System.Drawing.Size(75, 23);

this.submitButton.TabIndex = 7;

this.submitButton.Text = "Submit";

this.submitButton.UseVisualStyleBackColor = true;

//

// reloadButton

//

this.reloadButton.Location = new System.Drawing.Point(17, 11);

this.reloadButton.Name = "reloadButton";

this.reloadButton.Size = new System.Drawing.Size(75, 23);

this.reloadButton.TabIndex = 6;

this.reloadButton.Text = "Reload";

this.reloadButton.UseVisualStyleBackColor = true;

//

// dataGridView

//

this.dataGridView.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;

this.dataGridView.Location = new System.Drawing.Point(6, 106);

this.dataGridView.Name = "dataGridView";

this.dataGridView.Size = new System.Drawing.Size(451, 372);

this.dataGridView.TabIndex = 5;

//

// serviceController

//

this.serviceController.ServiceName = "SAFserverService";

//

// statusForm

//

this.ClientSize = new System.Drawing.Size(292, 266);

this.Name = "statusForm";

this.Load += new System.EventHandler(this.statusForm_Load_1);

this.tabControl.ResumeLayout(false);

this.controlPage.ResumeLayout(false);

this.controlPage.PerformLayout();

this.dbPage.ResumeLayout(false);

this.dbPage.PerformLayout();

((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Label StatusLabel;

private System.Windows.Forms.CheckBox chkLogging;

private System.Windows.Forms.TabControl tabControl;

private System.Windows.Forms.TabPage controlPage;

private System.Windows.Forms.TabPage dbPage;

private System.Windows.Forms.Button submitButton;

private System.Windows.Forms.Button reloadButton;

private System.Windows.Forms.Button StopButton;

private System.Windows.Forms.Button StartButton;

private System.ServiceProcess.ServiceController serviceController;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.TextBox listenPort;

private System.Windows.Forms.CheckBox checkLogging;

}
 
Well, for some reason the line of code:
this.Controls.Add(this.tabControl);
was missing from InitializeComponent().
The way I figured it out was to copy the project, then add another
tabControl to the form and then look at designer.cs for whatever changes had
been made. What caused this line to disappear? I don't know, but anyway
learnt a few things along the way to figuring it out.
 
Back
Top