简体   繁体   English

C#-动态创建的控件重叠

[英]C# - Dynamically created controls overlapping

I'm creating a notepad type of application which has the tab functionality. 我正在创建具有选项卡功能的记事本类型的应用程序。

I have a MenuStrip at the top and I'm creating the TabControl, its TabPages and the RichTextBoxes at run-time and I have set the DockStyle of the TabControl as Fill. 我在顶部有一个MenuStrip,并在运行时创建TabControl,其TabPages和RichTextBoxes,并将TabControl的DockStyle设置为Fill。 My problem is when I run the program the TabContol appears under the MenuStrip. 我的问题是,当我运行程序时,TabContol出现 MenuStrip下。 It looks like this, 看起来像这样

在此处输入图片说明

when it should look like this, below the MenuStrip. 应该在MenuStrip 下方看起来像这样。 (for this screenshot only I added the TabControl at design time) (仅对于此屏幕截图,我在设计时添加了TabControl)

在此处输入图片说明

I think the reason is the TabControl gets created on the form before the MenuStrip does. 我认为原因是在MenuStrip之前在窗体上创建了TabControl。 How can I overcome this issue? 我该如何克服这个问题?

Thank you. 谢谢。

使用SetChildIndex

form1.Controls.SetChildIndex(tabControl1, 0);

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM