I have a a .NET 3.5 windows form which I'd like to embed into another form. Is there a quick way to turn that form into a control?
Thanks
I have a a .NET 3.5 windows form which I'd like to embed into another form. Is there a quick way to turn that form into a control?
Thanks
Change the form to inherit from UserControl instead of Form, then fix any compile errors.
There's also a way to embed a form in a control: Here's the code in VB:
Public Shared Sub ShowFormInControl(ByRef ctl As Control, ByRef frm As Form)
If ctl IsNot Nothing AndAlso frm IsNot Nothing Then
frm.TopLevel = False
frm.FormBorderStyle = FormBorderStyle.None
frm.Dock = DockStyle.Fill
frm.Visible = True
ctl.Controls.Add(frm)
End If
End Sub
I think I acquired this code from another post on SO, but I can't remember where, so sorry if this is your code snippet!
Not saying that you should do this now but in the future you can take a look at MEF. Its a framework for (among other things) building composite applications which it sounds like might be what you're trying to achieve.