A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Transparent forms (form opacity)
Covers how to change the opacity of a form (making a form transparent) and making only portions of the form transparent using TransparencyKey.
On Saturday, October 23rd 2004 at 05:42 AM
By Andrew Pociu (View Profile)
(Rated 4.3 with 30 votes)
Add to buttons to a form (btnIncrease and btnDecrease), one will increase the opacity of the form and one will decrease it, thus making it more transparent.
Also if you want to check out the current opacity you can add a TextBox (txtCurrOp) that will display it.
Now double click each of the buttons. For the Click event of the btnDecrease button use the following code:
And for the btnIncrease Click event:
Here's how the form looks with the opacity 0.75 (that means 75%):
Making portions of the form transparent (TransparencyKey)
But there's more than this, you can set the opacity for different portions of the form using the TransparencyKey property. By setting this property to a specified color any part of the form that has that color will be transparent.
Let's test this, double click the form to get to the Form1_Load event. Paste the following code there:
This will make everything that's black on the form, transparent. The text on the buttons, label and TextBox is black, so are the Minimize, Maximize and Close buttons, thus they will be transparent. Here is the form on top of a photo (clouds):
But there's another way of using TransparencyKey. Add a Panel (Panel1) to the form with the BackColor property set to Red.
Inside the Load event of Form1 use the following:
As you might expect, Panel1, being red will actually be transparent:
Also by using TransparencyKey you can create custom shaped forms, but this will be covered in a soon to come tutorial.
|Digg It! Del.icio.us Reddit StumbleIt Newsvine Furl BlinkList|
Rate this tutorial
There are no related tutorials.
Related Source Code
There is no related source code.
C# Job Search