- This topic explains how to draw hollow text using vb.net
- It is done with the help of drawing class. All are done in the form paint event.
DRAWING CLASS – How to draw hollow text using vb.net
- System.Drawing namespace provides access to GDI+ basic graphic functionality.
- Main functions of Drawing are
System.Drawing.Drawing2D
System.Drawing.Imaging
System.Drawing.Text
- Graphics class provide methods for drawing to the display devices.
- Rectangle and Point Class encapsulates GDI+ primitives.
- Pen Class is used to draw lines and curves.
- Brush Class is used to fill interiors of shapes.
Graphics.DrawRectangle Method – How to draw hollow text using vb.net
- Draws a rectangle specified by a coordinate pair, a width, and a height.
Pen Class – How to draw hollow text using vb.net
- Defines an object used to draw lines and curves. This class cannot be inherited.
Graphics.SmoothMode Property – How to draw hollow text using vb.net
- It helps to get or set the rendering quality for this Graphics.
Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
- Syntax
|
1 2 |
'Declaration Public Property SmoothingMode As SmoothingMode |
Graphics.DrawPath Method – How to draw hollow text using vb.net
- Helps to draw a graphics path
- Syntax
|
1 2 3 4 5 |
'Declaration Public Sub DrawPath ( _ pen As Pen, _ path As GraphicsPath _ ) |
Graphics.FillPath Method – How to draw hollow text using vb.net
- Helps to fill the interior of the graphics path
- Syntax
|
1 2 3 4 5 |
'Declaration Public Sub FillPath ( _ brush As Brush, _ path As GraphicsPath _ ) |
How to draw hollow text using vb.net – Complete Code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'draw again when maximize Me.ResizeRedraw = True End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint ' Make things smoother. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias ' Create the text path. Dim path As New GraphicsPath(FillMode.Alternate) ' Draw text using a StringFormat to center it on the ' form. Using font_family As New FontFamily("Times New Roman") Using stringformat As New StringFormat() stringformat.Alignment = StringAlignment.Center stringformat.LineAlignment = StringAlignment.Center path.AddString("Hollow Text" & vbNewLine & "Hollow Text", font_family, _ CInt(FontStyle.Bold), 100, _ Me.ClientRectangle, stringformat) End Using End Using ' Fill and draw the path. e.Graphics.FillPath(Brushes.Azure, path) Using pen As New Pen(Color.Blue, 3) e.Graphics.DrawPath(pen, path) End Using End Sub End Class |






