Search code examples
vb.netwinformssplash-screen

Splash screen used before opening a form not loading controls


I have a form that takes a bit to load (needs to fetch some values from the database).

So I made a simple "please wait" splash screen, show it before intancing the form, close it and show the form:

Dim sp As New SplashScreen2
sp.Show()
Dim a = New AsignarFormacionesUsuario(p)
a.Text = "Asignar formaciones a: " + p.NomComplet
a.Show()
sp.Close()

The problem is that the splash screen does not loas the controls correctly:

How its seen

It should be:

How it should be

If I remove the intancing and showing of my form (and the closing of the splash so it does not instantly close) it's shown perfectly.

So it seems to not be a problem of the splash but a that the instancing of the form dont let the splash load correctly.

I don't know what to try, It seems that i just need the instancing to wait for the splash Show() to finish. But shouldn't it wait already?


Solution

  • Dim sp As New SplashScreen2  
    sp.Show()  
    
    sp.Update() 
    
    Dim a = New AsignarFormacionesUsuario(p)