The specific application of drawing with GDI in VB. NET.

Source: Internet
Author: User

The following example uses the OnPaint () method of the Form1 form to draw a GDI image.
Protected Overrides Sub onpaint (ByVal e As System. Windows. Forms. PaintEventArgs)
'// Draw any line
Dim g As Graphics = e. Graphics
Dim mypen As Pen = New Pen (Color. Red, 2)
G. DrawLine (mypen, 100,100, 10, 10)
'////////// Draw a rectangle (closed image composed of any straight lines)
Dim point1 As PointF = New PointF (100F, 100F)
Dim point2 As PointF = New PointF (200F, 100F)
Dim point3 As PointF = New PointF (200F, 200F)
Dim point4 As PointF = New PointF (100F, 200F)
Dim curvepoints As PointF () = {point1, point2, point3, point4}
G. DrawPolygon (New Pen (Color. Blue, 2), curvepoints)
'// Text Representation
Dim FFamily As FontFamily = New FontFamily ("Arial ")
Dim font As Font = New Font (FFamily, "20", FontStyle. Bold, FontStyle. Italic, GraphicsUnit. Pixel)
Dim text As String = "I love you! "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.