PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Round the corners of rectangles and controls.-VBForums
Results 1 to 4 of 4

Thread: Round the corners of rectangles and controls.

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Round Corners of Rectangles and Controls.

    Some times we want to draw rounded rectangles or show a form or controls with rounded corners. This class gives you that functionality. The class has two functions "RoundedRectangle" and "RoundedRegion". The "RoundedRectangle" rounds the corners of the rectangle and returns the graphics path. The "RoundedRegion" creates a rectangle-region, rounds the corners and returns the newly created region.

    Class Shared Methods:
    • RoundedRectangle – Returns the graphics path of the rounded-rectangle (parameters: rectangle, radius and four optional parameters for each corner).
    • RoundedRegion – Returns a newly created region with rounded corners (parameters: region size, radius and four optional parameters for each corner).

    Usage:
    VB Code:
    1. 'Draw a rounded rectangle in the form's paint event.
    2. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    3.     e.Graphics.DrawPath(Pens.Red, Shape.RoundedRectangle(New Rectangle(5, 5, 100, 100), 8, Shape.Corner.None))
    4. End Sub
    5.  
    6. 'Show the control on the form with rounded corners.
    7. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.     Me.Panel1.Region = Shape.RoundedRegion(Panel1.Size, 10, Shape.Corner.None)
    9. End Sub

    Please feel free to comment or notify me about any problems associated with the class.

    Download the latest version here
    Attached Images Attached Images    
    Attached Files Attached Files

  2. #2
    New Member
    Join Date
    Apr 2010
    Posts
    1

    Re: Round the corners of rectangles and controls.

    How could you make all the form corners (me.region) rounded? When I Try the Shape.Corner.BottomRight & so on, it only makes the first two rounded. When I call two instances, it gives me an error.

  3. #3

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Round the corners of rectangles and controls.

    Quote Originally Posted by Steve323 View Post
    How could you make all the form corners (me.region) rounded? When I Try the Shape.Corner.BottomRight & so on, it only makes the first two rounded. When I call two instances, it gives me an error.
    Me.Panel1.Region = Shape.RoundedRegion(Panel1.Size, 10, Shape.Corner.None)

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    20

    Re: Round the corners of rectangles and controls.

    A control with rounded corners should have set 'BorderStyle=None' ... !!

    Dietrich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width