Transparent Label .Net Control


This article explains how to create transparent Label controls in .NET Compact Framework, uLabelX Transparent Label Control that support border styles, Images, and parent controls with gradient backgrounds

Introduction



I think many people are facing trouble with creating a transparent label over a gradient background painted control.

This article illustrates an approach to showing transparent Labels in a Windows based application. uLabelX control in this library has designed to be flexible and stylish in their look. First of all, they support border shapes, Images and parent controls with gradient backgrounds, Images you have associated with control can be drawn in Alpha Blended form. Texts in the control can be drawn with advanced effects. All these attraction can also be personalized for different states of the controls.

Using the code



The project contains the following files

BorderStyles.vb (Specifies the border style of the Control)
ImageSizes.vb (Specifies the Image Size of the Control)
uLabelXDesigner.vb (Specifies the class used to implement design-time services for the control)
uLabelX.vb (Specifies the custom Control Class)

The Control Class uLabelX Inherited from the base class Control

Public Class uLabelX 
Inherits Control


Constructor



Public Sub New()
InitializeComponent()
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.Opaque, False)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
AddHandler Me.PropertyChanged, AddressOf OnPropertyChanged
RaiseEvent PropertyChanged(False)
End Sub


Events


Event Declaration



Protected Event PropertyChanged(ByVal _RecreateHandle As Boolean) 


Method Invoked when Property Changed



Private Sub OnPropertyChanged(ByVal _RecreateHandle As Boolean) 
If (_RecreateHandle = True) Then Me.RecreateHandle()
Me.Invalidate()
End Sub



Happy programming !!!

Reference: http://www.codeproject.com/KB/vb/uLabelX.aspx


Attachments

  • Transparent Label Source (40284-181312-uLabelXControlSource.zip)
  • Transparent Label Demo (40284-181313-uLabelXDemo.zip)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: