0

I placed several panels on my form. When I clicked the central panel in the designer, the main form was what was actually selected (even though the panel should be on top of it, and the main form should not be (easily) clickable in the designer).

By the way, clicking the other panels on the form don't have this problem (all of the other panels are on top of the form).

Because of the form being clicked when I expected that I was clicking the panel, when I added several controls to what I thought was the panel (after successfully adding some labels on top of the panel), all of these controls (checkboxes) ended up on the form / below the panel, so that they don't display at runtime:

enter image description here

When I realized that the controls were on the form, and not on the panel, I selected the form from the Property browser, selected all of the checkboxes at once, and cut the group of them.

I then selected the main panel from the Property Browser, and pasted those cut checkboxes onto the panel. It sort of worked, but all I saw was their outline (all selected together). I used the Ctrl+Up arrow to move them in a body up on the panel, a little at a time, until they were all near the top where they belong. But then they just disappeared.

From now on I will make sure to right-click the panel and select "BringToFront" before adding any controls to that area; for now, though, I don't see the checkboxes on either the form or the panel. How can I get them back (and place them on the panel), and prevent the form from ever appearing on top of the panel (except if/when I select it from the Property browser)?

The checkboxes do still exist, although their names were changed from "ckbxAll" etc. to Checkbox1, etc. They appear on the correct panel in Form1Designer.cs, but do not display. Here is how they are represented there:

// panelMain
// 
this.panelMain.BackColor = System.Drawing.Color.White;
this.panelMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelMain.Controls.Add(this.checkBox21);
this.panelMain.Controls.Add(this.checkBox20);
this.panelMain.Controls.Add(this.checkBox19);
this.panelMain.Controls.Add(this.checkBox18);
this.panelMain.Controls.Add(this.checkBox17);
this.panelMain.Controls.Add(this.checkBox16);
this.panelMain.Controls.Add(this.checkBox15);
this.panelMain.Controls.Add(this.checkBox14);
this.panelMain.Controls.Add(this.checkBox13);
this.panelMain.Controls.Add(this.checkBox12);
this.panelMain.Controls.Add(this.checkBox11);
this.panelMain.Controls.Add(this.checkBox10);
this.panelMain.Controls.Add(this.checkBox9);
this.panelMain.Controls.Add(this.checkBox8);
this.panelMain.Controls.Add(this.checkBox7);
this.panelMain.Controls.Add(this.checkBox6);
this.panelMain.Controls.Add(this.checkBox5);
this.panelMain.Controls.Add(this.checkBox4);
this.panelMain.Controls.Add(this.checkBox3);
this.panelMain.Controls.Add(this.checkBox2);
this.panelMain.Controls.Add(this.checkBox1);
this.panelMain.Location = new System.Drawing.Point(160, 0);
this.panelMain.Name = "panelMain";
this.panelMain.Size = new System.Drawing.Size(639, 740);
this.panelMain.TabIndex = 2;
// 

UPDATE

It turns out they ARE there, but they are invisible now (except for their outlines when I click on them):

enter image description here

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 2
    It appears you have pasted these controls inside another container. Open up the Designer.cs file and see what container is the actual Parent. -- Try to use a TabControl without headers to switch between Panels, so you have the same simplified layout both at design-time and run-time. -- After edit: the layout you're showing doesn't reflect the description of the operations: when controls are cut and pasted, the original name is not lost. What you lose are the event handlers (still there, but not wired up) – Jimi Oct 19 '20 at 17:40
  • But that's exactly what happened. I had 21 custom-named checkboxes, and now they have all reverted to their default "number-names." – B. Clay Shannon-B. Crow Raven Oct 19 '20 at 19:41
  • I added an Update - they are indeed there, but are invisible (except for their outlines) – B. Clay Shannon-B. Crow Raven Oct 19 '20 at 20:36
  • 1
    @B.ClayShannon it will be hard to see what's going on without checking source. Would you be able to add source code for any one checkbox and it's properties which you added to the panel? – Dipen Shah Oct 19 '20 at 21:14
  • 1
    @DipenShah: Thanks, but it was irritating me too much to click on what I hoped was the panel, only to have the Form be what I clicked on (not having that problem with any of the other panels), so I simply deleted that middle panel and will add back those checkboxes onto the form. – B. Clay Shannon-B. Crow Raven Oct 19 '20 at 22:43
  • @Jimi: Part of the problem was that I was losing changes made in the .cs file when I had unsaved changes on it and clicked on the designer tab. I submitted a bug rpt to MS: If I click the Designer tab (such as "Form1.cs [Design]) after making changes in the code file (such as Form1.cs), the changes I made to the code file are not retained, and I am not prompted to save the changes as I move to the Design tab. – B. Clay Shannon-B. Crow Raven Oct 20 '20 at 20:07

0 Answers0