By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,266 Members | 1,300 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,266 IT Pros & Developers. It's quick & easy.

Transparent form, opaque label

P: n/a
I have Visual Basic .NET 2003, and wanted to create a form that only shows
the contents of a label.
The form can't have a title bar or border. It seriously needs to just be
the text inside the label.

Can this be done?

Matthew
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
> I have Visual Basic .NET 2003, and wanted to create a form that only shows
the contents of a label.


Me.FormBorderStyle = FormBorderStyle.None
Me.ControlBox = False
Me.TransparencyKey = Me.BackColor

I found the above code, and it makes everything go away except the
background for my label. I have tried setting the background color of the
label to transparent, but it is still an ugly grey color.

Matthew
Nov 21 '05 #2

P: n/a
> I have Visual Basic .NET 2003, and wanted to create a form that only shows
the contents of a label.


Me.FormBorderStyle = FormBorderStyle.None
Me.ControlBox = False
Me.TransparencyKey = Me.BackColor

I found the above code, and it makes everything go away except the
background for my label. I have tried setting the background color of the
label to transparent, but it is still an ugly grey color.

Matthew
Nov 21 '05 #3

P: n/a
23s
How about this:

Set the form border style to None

Set the background color of the form to some color you aren't likely to use,
like 'Magenta' (bright pink).

Set the transparency key of the form to Magenta (or whatever color you chose
above)

Put a label on the form. Set the label's background color to 'Transparent'.
Populate the label with some text, run the app / show the form and you
should only see the label text. Note this was tested in WinXP SP2, dunno if
other/older OS's have transparency issues with forms.

"Matthew" <tu*************@alltel.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have Visual Basic .NET 2003, and wanted to create a form that only shows
the contents of a label.
The form can't have a title bar or border. It seriously needs to just be
the text inside the label.

Can this be done?

Matthew

Nov 21 '05 #4

P: n/a
> Set the form border style to None

Set the background color of the form to some color you aren't likely to
use, like 'Magenta' (bright pink).

Set the transparency key of the form to Magenta (or whatever color you
chose above)

Put a label on the form. Set the label's background color to
'Transparent'. Populate the label with some text, run the app / show the
form and you should only see the label text. Note this was tested in
WinXP SP2, dunno if other/older OS's have transparency issues with forms.


Thanks for the response. I also have XP SP2. What a happy coincidence!

I folowed your steps, but the background of the label was Magenta. Was
there another setting you might have modified?
Or, if you have a working example, could you send it to me?

Thanks,

Matthew
Nov 21 '05 #5

P: n/a
> I have Visual Basic .NET 2003, and wanted to create a form that only shows
the contents of a label.
The form can't have a title bar or border. It seriously needs to just be
the text inside the label.


I think I figured it out.

Me.FormBorderStyle = FormBorderStyle.None
Dim Img As Bitmap = New Bitmap(10, 10)
Img.MakeTransparent(Img.GetPixel(1, 1))
Me.BackgroundImage = Img
Me.TransparencyKey = Img.GetPixel(1, 1)

For some reason, having the background as an image seems to be more
effective than making the TransparencyKey the BackColor:
Me.TransparencyKey = Me.BackColor

Matthew
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.