views:

523

answers:

5

I'm writing a simple app that's going to have a tiny form sitting in one corner of the screen, updating itself.

I'd really love for that form to be transparent and to have the transparency be user-configurable.

Is there any easy way to achieve this?

A: 

You can set the Form.Opacity property. It should do what you want.

Eric Haskins
+4  A: 

You could try using the Opacity property of the Form. Here's the relevant snippet from the MSDN page:

private Sub CreateMyOpaqueForm()
   ' Create a new form.
   Dim form2 As New Form()
   ' Set the text displayed in the caption.
   form2.Text = "My Form"
   ' Set the opacity to 75%.
   form2.Opacity = 0.75
   ' Size the form to be 300 pixels in height and width.
   form2.Size = New Size(300, 300)
   ' Display the form in the center of the screen.
   form2.StartPosition = FormStartPosition.CenterScreen

   ' Display the form as a modal dialog box.
   form2.ShowDialog()
End Sub
Cameron MacFarland
A: 

set Form.Opacity = 0.0 on page load

I set something like what your talking about on an app about a year ago. Using a while loop with a small sleep you can setup a nice fading effect.

Ethan Gunderson
A: 

I don't know exactly what you mean by transparent, but if you use WPF you can set AllowTransparency=true on your form and then remove the form's style/border and then set the background to a color that has a zero alpha channel. Then, you can draw on the form all you want and the background will be see-through and the other stuff will be fully visible. Additionally, you could set the background to a low-opacity layer so you can half see through the form.

Daniel Jennings
+1  A: 

Excellent. Even easier than I thought!

Mark Biek