简体   繁体   English

在Windows窗体中,在窗体上添加此控件后,控件的应用程序位置已更改

[英]In Windows forms application location of controls changed after adding this control on form

I am developing a Windows Forms application using Visual Studio 2010 and C#. 我正在开发使用Visual Studio 2010和C#Windows窗体应用程序。 I have created one user control to show a detail screen. 我创建了一个用户控件来显示详细信息屏幕。 When I added this user control on another form or user control in panel container then controls positions are changed. 当我将此用户控件添加到其他窗体或面板容器中的用户控件上时,控件的位置就会更改。 I used the doc property, but still see this issue. 我使用了doc属性,但仍然看到此问题。

PanelCancelledConainer.Controls.Clear();
InquiryDetailsCls.InquiryID = Convert.ToInt32(GridInquiry.SelectedRows[0].Cells[0].Value.ToString());
CtrlInqDetails inqDetails = new CtrlInqDetails(InquiryDetailsCls.InquiryID, 1);
inqDetails.Dock = DockStyle.Fill;
PanelCancelledConainer.Controls.Add(inqDetails);

What can I do so that user controls look as they do in design mode? 我该怎么做,以使用户控件看起来像在设计模式下一样?

Images added from Comments: 图片来自评论:

在此处输入图片说明

在此处输入图片说明

try to set index position of your usercontrol on the container that is: 尝试设置用户控件在容器上的索引位置,即:

PanelCancelledConainer.Controls.SetChildIndex(inqDetails, 0); 

you will be sure that it was the first child. 您将确定它是第一个孩子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将控件添加到Windows窗体表单 - adding controls to a Windows Forms Form 将控件添加到标签页后,其位置已更改 - Location of controls got changed after adding it to a tabpage Windows窗体应用程序C#-选项卡控件项在调试模式下运行后移动位置 - Windows Forms Application C# - Tab Control items shift location after running on debug mode 如何遍历Windows窗体表单中的所有控件或如何查找特定控件是否是容器控件? - How to loop through all controls in a Windows Forms form or how to find if a particular control is a container control? 在Windows Forms应用程序中使用Windows Store控件 - Using Windows Store controls in a Windows Forms application 从 Windows 窗体控件中按名称查找控件 - Find control by name from Windows Forms controls C#Windows窗体:如何在没有Controls.Add的情况下将控件添加到InitializeComponent()下的窗体 - C# Windows Forms: How the Control is added to the Form under InitializeComponent() without Controls.Add 在Windows窗体应用程序中重复控件 - Repeating controls in windows form application Windows窗体边框和窗体控件 - Windows Forms border and form control 如何在运行时以vb.net窗体形式更改TableLayoutPanel控件中控件的位置 - how to change the location of controls in TableLayoutPanel control at runtime in vb.net windows form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM