Transparent ListBox

geezup_2000

Newcomer
Joined
Dec 12, 2005
Messages
3
Hi there !

I need help with transparency and listboxes.

The code below actually makes the listbox so transparent that items added to it are also transparent, unless you click them. When you release the mouse click, item goes back to transparent state.

Any help would be appreciated. Thanks in advance.

Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel

Public Class CustomListBox : Inherits ListBox

' Properties

<DefaultValueAttribute(GetType(System.Drawing.Color), "Transparent")> _
Public Overrides Property BackColor() As System.Drawing.Color
Get
Return MyBase.BackColor
End Get
Set(ByVal Value As System.Drawing.Color)
MyBase.BackColor = Value
End Set
End Property


' Methods
Public Sub New()

MyBase.New()
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.UserPaint, True)
Me.customInitialisation()

End Sub

Private Sub customInitialisation()

Me.SuspendLayout()
Me.BackColor = Color.Transparent
Me.ForeColor = Color.Black
Me.ResumeLayout(False)

End Sub


Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
End Sub

End Class
 
Back
Top