Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...