In VB.NET it's easy to fill a form with a gradient. I made this function that
will fill a form with a gradient using the colors specified by 2 Color objects
and a LinearGradientMode type. It can be used like this: Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
DrawGradient(Color.Blue, Color.Firebrick, Drawing.Drawing2D.LinearGradientMode.Horizontal)
End Sub
The function is: Private Sub DrawGradient(ByVal color1 As Color, ByVal color2
As Color, ByVal mode As System.Drawing.Drawing2D.LinearGradientMode)
Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New
RectangleF(0, 0, Me.Width, Me.Height), color1, color2, mode)
Dim g As Graphics = Me.CreateGraphics
g.FillRectangle(a, New RectangleF(0, 0, Me.Width, Me.Height))
g.Dispose()
End Sub
You can render text using a similiar method: Private Sub DrawGradientString(ByVal text as String, ByVal
color1 As Color, ByVal color2 As Color, ByVal mode As System.Drawing.Drawing2D.LinearGradientMode)
Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New
RectangleF(0, 0, 100, 19), color1, color2, mode)
Dim g As Graphics = Me.CreateGraphics
Dim f As Font
f = New Font("arial", 20, FontStyle.Bold, GraphicsUnit.Pixel)
g.DrawString(text, f, a, 0, 0)
g.Dispose()
End Sub
For this method it is used like this: DrawGradientString("Hello To You", Color.blue, Color.firebrick,
Drawing.Drawing2D.LinearGradientMode.Vertical)
Isn't that easy compared to VB6?
Drawing A Color Gradient
You might also like...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
.NET Rocks: Eric Lippert Talks About Project Roslyn
Published 9 years ago, running time 0h56m
Recorded on PI day, Carl and Richard talk to the one-and-only Eric Lippert from the C# Compiler team. But we don't only talk about C#! The conversation wanders around all the languages, a little F#, a little IronPython, heck, even VB.NET! Eric talks about Project Roslyn, Microsoft's efforts to ma.
Comments