Programatically created label stays invisible. Why?

W

What-a-Tool

Decided to try and do it this way just to see if I could. My form appears
with a rectangular hole in the center the size of my label. can anyone tell
me why, and if it can be made visible?

Thanks, Sean

Sub Main()

'Create and format splash form

Dim frmSplash As New Form()

Dim SplashRect As New Rectangle(0, 0, 360, 252)

Dim lblSplashIntro As New Label()

frmSplash.DesktopBounds = SplashRect

frmSplash.FormBorderStyle = FormBorderStyle.None

frmSplash.BackColor = System.Drawing.Color.LightSteelBlue

frmSplash.StartPosition = FormStartPosition.CenterScreen

frmSplash.TopMost = True

lblSplashIntro.Font = New System.Drawing.Font _

("Tahoma", 15.75!, _

System.Drawing.FontStyle.Regular, _

System.Drawing.GraphicsUnit.Point, CType(0, Byte))

lblSplashIntro.Text = "Hey, where am I !!"

lblSplashIntro.Location = New Point(50, 100)

lblSplashIntro.Size = New Size(260, 50)

lblSplashIntro.BackColor = System.Drawing.Color.LightSteelBlue

lblSplashIntro.Enabled = True

lblSplashIntro.Visible = True

frmSplash.Controls.Add(lblSplashIntro)

frmSplash.Show()

'Sleeps for 3 seconds to display splash form

Thread.CurrentThread.Sleep(3000)

frmSplash.Close()

End Sub
 
A

Armin Zingler

What-a-Tool said:
Decided to try and do it this way just to see if I could. My form
appears with a rectangular hole in the center the size of my label.
can anyone tell me why, and if it can be made visible?

[...]
frmSplash.Show()

'Sleeps for 3 seconds to display splash form

Thread.CurrentThread.Sleep(3000)


When you put the thread to sleep, the splash form is not painted.

To force it to repaint itself immediatelly, call
frmSpash.Refresh
directly after calling Show.
 
H

Herfried K. Wagner [MVP]

Hello,

What-a-Tool said:
Decided to try and do it this way just to see if I could. My
form appears with a rectangular hole in the center the size of my
label. can anyone tell me why, and if it can be made visible?

Are you sure the 'TransparencyKey' property of the form is not set?
frmSplash.Controls.Add(lblSplashIntro)

frmSplash.Show()

Call 'lblSplashIntro.Refresh' or 'frmSplash.Refresh' here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top