[英]Winform - SetFocus to textbox inside usercontrol on TabControl
[英]Displaying a UserControl inside a WinForm
我正在研究一个从Form类继承的类库,然后在Gui应用程序中显示此表单。 现在,我需要将类库更改为UserControl
。
如何在另一个项目的表单内部显示它? 预先感谢您的建议。
IFaceForm是InterfaceLibrary内部的usercontrol。
using InterfaceLibrary;
namespace MxlInterface
{
public partial class IFaceConn : Form
{
iFaceForm Interface = new iFaceForm();
//size of the parent form is 881,514
//use these variables to change the position of the "Interface Form"
int xlocation = 0;
int ylocation = 0;
public IFaceConn()
{
InitializeComponent();
//Interface.StartPosition = FormStartPosition.Manual;
Interface.Location = new Point(xlocation, ylocation);
//Interface.MdiParent = this;
Interface.Show();
}
}
}
您可以通过执行以下操作将其直接添加到表单中:
MyUserControl myControl = new MyUserControl();
Controls.Add(myControl);
在Panel
上放置一个可以作为用户控件占位符的Panel
,然后将用户控件添加到该面板中,这通常也很有用:
MyUserControl myControl = new MyUserControl();
myControlWrapperPannel.Controls.Add(myControl;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.