Octopus Brother produced-vb.net how to draw rounded rectangles and fit the form size

Source: Internet
Author: User

Public Class Form1 ' ********************************************************************* ' octopus brother, qq:3107073263 Group: 30         9816713 ' If you have any questions or good suggestions please contact me, everyone progress together ' ********************************************************************* ' Draw Rounded Rectangle function Private function Getroundedrectpath (ByVal rect as Rectangle, ByVal radius as Integer) as System.Drawing. Drawing2d.graphicspath rect. Offset ( -1,-1) Dim RoundRect as New Rectangle (rect. Location, new Size (Radius-1, radius-1)) Dim path as New System.Drawing.Drawing2D.GraphicsPath path. AddArc (RoundRect, 180, 90) ' upper left corner roundrect.x = rect. Right-radius ' upper right corner path. AddArc (RoundRect, +) Roundrect.y = rect. Bottom-radius ' lower right corner path. AddArc (roundrect, 0, roundrect.x) = rect. Left ' bottom ' path. AddArc (RoundRect,,) path. Closefigure () Return path End Function ' Draw rectangle Private Sub drawingrect () Dim g as Graphics = me.cReategraphics ' defines a canvas dim Pen As New Pen (brushes.darkred, 2) ' defines a brush dim Hei as Integer = Me.height D Im Wid as Integer = Me.Width ' rectangle's position and length change as the form changes Dim Rec as New Rectangle (int (WID/5), int (HEI/5), int (Wi D/2), Int (HEI/2)) ' G.drawrectangle (Pen, Rec) ' Clear existing rectangle g.clear (me.backcolor) G.drawpath (P En, Getroundedrectpath (Rec.)) End Sub Private Sub form1_paint (ByVal sender as System.Object, ByVal e as System.wi Ndows. Forms.painteventargs) Handles mybase.paint drawingrect () End Sub Private Sub form1_sizechanged (ByVal sender A S System.Object, ByVal e as System.EventArgs) Handles mybase.sizechanged me.invalidate () ' This function can raise the paint event End Sube nd Class


Original form drawing:

When shrinking a form:

Octopus Brother produced-vb.net how to draw rounded rectangles and fit the form size

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.