R
ray well
in my app i need to make a RichTextbox control transparent.
i need it to be a like a pane of glass lying on a sheet of paper, where u
can see everything on the sheet of paper not covered by text written on the
glass pane. i need to be able to see the control or form that is underneath
the RichTextbox, and at the same time to be able to write and erase text to
the RichTextbox.
i'm assuming that it is the backcolor that hides what is underneath a
control. so i tried setting rtb.BackColor = Color.Transparent.
when u do that u get a error that BackColor may not be Color.Transparent.
bummer. i looked for help and found the following link on the cd that came
with net 2005
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/html/32433e63-f4e9-4305-9857-6de3edeb944a.htm
the heading is:
How to: Give Your Control a Transparent Background
in it it tells u the following:
========================
By default, controls do not support transparent backcolors. However, you can
allow your control to have a background color that is opaque, transparent,
or partially transparent by using the Control.SetStyle Method in the
constructor. The SetStyle method of the Control class allows you to set
particular style preferences for your controls, and can be used to enable or
disable support for transparent backcolors.
To give your control a transparent backcolor
Locate the constructor for your control class.
Call the SetStyle method of your form in the constructor.
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
This will enable your control to support a transparent backcolor.
Beneath the line of code you added in step 1, add the following line. This
will set your control's BackColor to Transparent.
Me.BackColor = Color.Transparent
======================================
i subclassed the RichTextbox control, added a constructor, as follows: (i
tried Me.SetStyle(ControlStyles.Opaque, False)
& Me.SetStyle(ControlStyles.Opaque, True) & omitting it alltogether, it
didn't help.)
---------------
Public Class clsRtbx
Inherits System.Windows.Forms.RichTextBox
Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.SetStyle(ControlStyles.Opaque, False)
Me.BackColor = Color.Transparent
End Sub
End Class
--------------
to test it, i did the following in the Form_Load event
Dim rtb2 As New clsRtbx
rtb2.Text = ""
rtb2.Top = 0
rtb2.Left = 0
rtb2.Width = 300
rtb2.Multiline = True
rtb2.Height = 200
rtb2.BackColor = Color.Transparent 'i tried with this line, and without
it
Me.Controls.Add(rtb2)
rtb2.BringToFront()
when i did this, i did not get the color transparency error, but it still
hides everything underneath itself!
am i missing something?
i would greatly appreciate to find out if a control can be make transparent
(as explained above, to see what is underneath it, while being able to
write/erase to it), and how to do it.
thanks, ray
i need it to be a like a pane of glass lying on a sheet of paper, where u
can see everything on the sheet of paper not covered by text written on the
glass pane. i need to be able to see the control or form that is underneath
the RichTextbox, and at the same time to be able to write and erase text to
the RichTextbox.
i'm assuming that it is the backcolor that hides what is underneath a
control. so i tried setting rtb.BackColor = Color.Transparent.
when u do that u get a error that BackColor may not be Color.Transparent.
bummer. i looked for help and found the following link on the cd that came
with net 2005
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/html/32433e63-f4e9-4305-9857-6de3edeb944a.htm
the heading is:
How to: Give Your Control a Transparent Background
in it it tells u the following:
========================
By default, controls do not support transparent backcolors. However, you can
allow your control to have a background color that is opaque, transparent,
or partially transparent by using the Control.SetStyle Method in the
constructor. The SetStyle method of the Control class allows you to set
particular style preferences for your controls, and can be used to enable or
disable support for transparent backcolors.
To give your control a transparent backcolor
Locate the constructor for your control class.
Call the SetStyle method of your form in the constructor.
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
This will enable your control to support a transparent backcolor.
Beneath the line of code you added in step 1, add the following line. This
will set your control's BackColor to Transparent.
Me.BackColor = Color.Transparent
======================================
i subclassed the RichTextbox control, added a constructor, as follows: (i
tried Me.SetStyle(ControlStyles.Opaque, False)
& Me.SetStyle(ControlStyles.Opaque, True) & omitting it alltogether, it
didn't help.)
---------------
Public Class clsRtbx
Inherits System.Windows.Forms.RichTextBox
Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.SetStyle(ControlStyles.Opaque, False)
Me.BackColor = Color.Transparent
End Sub
End Class
--------------
to test it, i did the following in the Form_Load event
Dim rtb2 As New clsRtbx
rtb2.Text = ""
rtb2.Top = 0
rtb2.Left = 0
rtb2.Width = 300
rtb2.Multiline = True
rtb2.Height = 200
rtb2.BackColor = Color.Transparent 'i tried with this line, and without
it
Me.Controls.Add(rtb2)
rtb2.BringToFront()
when i did this, i did not get the color transparency error, but it still
hides everything underneath itself!
am i missing something?
i would greatly appreciate to find out if a control can be make transparent
(as explained above, to see what is underneath it, while being able to
write/erase to it), and how to do it.
thanks, ray