2
Besides using Splitcontainer, is there any other way to put a Form inside another form, using HTML’s iframe style? Because Splitcontainer I am not able to change the Form data inside it.
2
Besides using Splitcontainer, is there any other way to put a Form inside another form, using HTML’s iframe style? Because Splitcontainer I am not able to change the Form data inside it.
2
I have been researching, there are many ways to accomplish this, here is a list with possibilities and attempts that you can make:
Place this method in the base class (where you will add the controls):
Public Function PerformControls(ByVal Expression As Form) As Control
Dim tmp As New Control With
{
.Size = Expression.Size,
.Location = Expression.Location,
.Cursor = Expression.Cursor,
.Font = Expression.Font,
.BackColor = Expression.BackColor,
.ForeColor = Expression.ForeColor
}
For Each item As Object In Expression.Controls
tmp.Controls.Add(item)
Next
Return tmp
End Function
To use, try like this:
Private Sub Form_Load(sender As [Object], e As EventArgs) Handles MyBase.Load
Me.Controls.Add(PerformControls(New FormDest)) 'FormDest é o nome da classe destino
End Sub
Add this function:
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
To use:
Private Sub Form_Load(sender As [Object], e As EventArgs) Handles MyBase.Load
ShowFormInControl(Me, New frmDest)
End Sub
Try it, good luck.
Browser other questions tagged winforms vb.net
You are not signed in. Login or sign up in order to post.
Had already tried, reports error: It is not possible to add top level control to a control.
– Leonardo Joksan
Try to put:
Dim frmHost As Control = FormDest.AtacchedControl
.– CypherPotato
Error informs: Cannot add top level control to a control.
– Leonardo Joksan