Programatically created label stays invisible. Why?

  • Thread starter Thread starter What-a-Tool
  • Start date Start date
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
 
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.
 
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.
 
Back
Top