Question Open a sub-form into the form

Moradazo

New member
Joined
Aug 20, 2021
Messages
1
Programming Experience
10+
Hi there,

I am using VB.net 2015.

I have received a popup with the following error:

An error occurred creating the form. See Exception.InnerException for details. The error is: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

This happens when my form tries to load another form with the following code:

VB.NET:
Private Sub AbrirFormPanel(Of miform As {Form, New})()
    Dim formulario As Form
    
    formulario = Panelformularios.Controls.OfType(Of miform)().FirstOrDefault() 'Busca el formulario en la colección
    
    If formulario Is Nothing Then
        formulario = New miform()
        formulario.TopLevel = False
        formulario.FormBorderStyle = FormBorderStyle.None
        formulario.Dock = DockStyle.Fill
        Panelformularios.Controls.Add(formulario)
        Panelformularios.Tag = formulario
        formulario.Show()
        formulario.BringToFront()
    Else
        formulario.BringToFront()
    End If
End Sub

Does anyone know what would happens there?

Thanks!
 
Last edited by a moderator:

Latest posts

Back
Top