C#-将视觉形式加载到另一种形式 [英] C# - load visual form into another form
问题描述
你好
当我单击几个按钮时,我试图一次将多个表单加载到一个地方.
我有放置所有按钮和控件的主窗体,然后我想将其他一些窗体加载到同一位置,也许是面板.
I have my main Form where all buttons and controls are placed and then i have some other forms that i want to load into the same place, maybe a Panel.
我尝试了一些未成功的代码:
I have tryed some codes witheout success:
private void Form1_Load(object sender, EventArgs e)
{
// The existant form name is formToLoad01 but this declares a new one, not the one i already have created with other controls in it
// Declaration of a new form, Why??????? i want the one existant
Form forToLoad01 = new Form();
forToLoad01.TopLevel = false; // Some specifications for the declared form
forToLoad01.AutoScroll = true; // Some specifications for the declared form
mainForm.mainPanel.Controls.Add(forToLoad01); // Assign what to what, doesnt work ???
forToLoad01.Show(); // This code should be in the button.
}
还有其他方法可以将其他预构建表单加载到我的主表单中的特定位置吗?
Is there another way of loading other prebuild form into a specific place in my main form?
还有另一种构建方式吗?另一个控件还是其他?我应该使用标签控件吗?
Is there another way of building this? Another control or something else? Should i use tabs control?
谢谢
Rui Ruivo
Rui Ruivo
推荐答案
刚刚找到了这个
just found this
https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/5eec7609-9d20-4b93-a13c-d40327d4abfe/how-to-load-a-form-inside-another-form-in -c-2008?forum = winforms
https://social.msdn.microsoft.com/Forums/vstudio/en-US/5eec7609-9d20-4b93-a13c-d40327d4abfe/how-to-load-a-form-inside-another-form-in-c-2008?forum=winforms
这篇关于C#-将视觉形式加载到另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!