[英]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.