我已经创建了一个用按钮、标签、文本框等填充的userControl。当我将它添加到我的FormMain中时,出现的只是一个150x150的灰色方块,而不是我的userControl应该是什么样子。我在这个项目中还有其他的userControls,它们的功能都很好。目前没有提供代码,因为根据我的另一个userControls,这应该发生在winforms上-对于这两个UC,我只是从工具箱中拖放。
当我添加一个“其他”userControls时会发生什么:
添加所需的userControl时会发生什么情况的图像:
我的userControl实际外观的图像:
在窗体主设计器中,它们被添加到此处的选项卡中...
this.tabPageTelescope.Controls.Add(this.userControlTelescope21);
this.tabPageTelescope.Controls.Add(this.userControlTelescope1);
稍后,它们会再次出现在这里。
// userControlTelescope1
//
this.userControlTelescope1.Location = new System.Drawing.Point(113, 55);
this.userControlTelescope1.Name = "userControlTelescope1";
this.userControlTelescope1.Size = new System.Drawing.Size(150, 150);
this.userControlTelescope1.TabIndex = 0;
//
// userControlTelescope21
//
this.userControlTelescope21.Location = new System.Drawing.Point(236, 13);
this.userControlTelescope21.Name = "userControlTelescope21";
this.userControlTelescope21.Size = new System.Drawing.Size(752, 587);
this.userControlTelescope21.TabIndex = 1;
两个userControlTelescope21都像预期的那样出现,userControl1才是有问题的那个。除了TabIndex之外,它们具有相同的属性。可能值得注意的是,userControlTelescope1的大小不是(150,150) -这就是它添加它的原因。
发布于 2019-06-04 04:37:22
在没有代码的情况下,我唯一能想到的就是确保您的控件是选项卡窗格的成员,而不是底层窗体。查看它们的属性面板或窗体设计器的代码。
https://stackoverflow.com/questions/56433746
复制相似问题