I want to make fade out effect for label but it does not have any opacity property, so how can I achieve the animation or how can I create a Property for opacity
Opacity Property and fade out effect in vb.net
Page 1 of 11 Replies - 179 Views - Last Post: 29 January 2013 - 12:49 PM
Replies To: Opacity Property and fade out effect in vb.net
#2
Re: Opacity Property and fade out effect in vb.net
Posted 29 January 2013 - 12:49 PM
Below is some code from this discussion. Alternatively, switch to WPF.
Imports System
Imports System.Drawing
Imports System.Windows.Forms
' <summary>
' A label that can be transparent.
' </summary>
Public Class TransparentLabel
Inherits Control
' <summary>
' Creates a new "TransparentLabel" instance.
' </summary>
Public Sub New()
TabStop = False
Dim transparencyValue As Integer = 15 '0 is all transparent, 255 is solid
ForeColor = Color.FromArgb(transparencyValue, ForeColor.R, ForeColor.G, ForeColor.B)/>
End Sub
' <summary>
' Gets the creation parameters.
' </summary>
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
' <summary>
' Paints the background.
' </summary>
' <param name="e">E.</param>
Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
' do nothing
End Sub
' <summary>
' Paints the control.
' </summary>
' <param name="e">E.</param>
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using brush As SolidBrush = New SolidBrush(ForeColor)
e.Graphics.DrawString(Text, Font, brush, -1, 0)
End Using
End Sub
End Class
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|