窗体中的 C# Winform 窗体 [英] C# Winform Forms in Form

查看:26
本文介绍了窗体中的 C# Winform 窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个表单的多个实例并以另一种形式或另一种形式的面板显示它.怎么做

解决方案

如果您不使用 MDI,您仍然可以将一个表单添加到另一个表单或表单上的面板.

public Form1(){初始化组件();Form2 EmbeddedForm = new Form2();EmbeddedForm.TopLevel = false;Controls.Add(embeddedForm);EmbeddedForm.Show();}

您需要将 FormBorderStyle 设置为 None,除非您想在表单中包含实际的可移动表单.

如果您想这样做以创建一个可重用的模板"以在多个表单中使用,您应该考虑创建一个用户控件.不要与自定义控件混淆,自定义控件适用于需要自己绘制而不是使用标准 Windows 控件集合的情况.

我不完全确定您的意图是什么,但 MDI(如其他答案之一所述)实际上可能就是您要寻找的.

i want to open multiple instances of one form and display it in another form or paenel of another form. how to do it

解决方案

If you're not using MDI, you can still add a form to another form, or to a panel on a form.

public Form1()
{
    InitializeComponent();

    Form2 embeddedForm = new Form2();
    embeddedForm.TopLevel = false;
    Controls.Add(embeddedForm);
    embeddedForm.Show();
}

You will need to set the FormBorderStyle to None, unless you want to have an actual movable form inside your form.

If you want to do this to create a reusable "template" to use in multiple forms, you should consider creating a user control instead. Not to be confused with a custom control, which is intended for when you need to do your own drawing instead of using collections of standard Windows controls.

I'm not entirely sure what your intentions are, but MDI (as mentioned in one of the other answers) might actually be what you're looking for.

这篇关于窗体中的 C# Winform 窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆