Reputation: 131
I am working on a class library that inherits from Form class and then displays this form inside of a Gui app. Now I need to change the class library into a UserControl
.
How do I go about displaying it inside of a form in another project? Thanks in advance for your suggestions.
IFaceForm is the usercontrol inside of the InterfaceLibrary.
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();
}
}
}
Upvotes: 0
Views: 5991
Reputation: 203826
You could add it to the form directly by doing something like:
MyUserControl myControl = new MyUserControl();
Controls.Add(myControl);
It's also often useful to place a Panel
that can be the placeholder for the user control on your form, and then add the user control to that panel:
MyUserControl myControl = new MyUserControl();
myControlWrapperPannel.Controls.Add(myControl;
Upvotes: 4