Click here to Skip to main content
13,868,372 members
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 20 Jan 2018
Licenced CPOL

RoundedButton Control - Demystifying DrawArc

, 21 Jan 2018
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "RoundedButton Control - Demystifying DrawArc"


An updated version of the RoundedButton control for VS2017, refactored and stylecopped.

V 1.3

Improved the drawing routine DrawBorderGraphic() the rough edges are now smoother:

In the GraphicsBuffer class, the "old style" properties were replaced by more modern one line equivalents.

This can be done very easily by following the hints in the margin displayed by the VS2017 editor:

public Bitmap BitmapX { get; set; }

public int WidthG { get; set; }

public int HeightG { get; set; }

public string NameG { get; set; }

/// <summary>
/// returns the current Graphic Graphics object
/// </summary>
public Graphics Graphic => (graphic);

/// <summary>
/// returns true if the graphics object exists; false otherwise
/// </summary>
public bool GraphicsBufferExists => (graphic != null);


As the test form did not show correctly because of overlap of the button with the controls, I decided to change the code so this would not happen, strangely the author did not seem to have this problem.

So when the roundedbutton is set to a very big height and is going to overlap the other controls in the groupboxes below, the groupboxes button_GB and border_GB are moved downwards and the form size is recalculated in the RecalculateSizes() method:

/// <summary>
/// Recalculate the form and groupbox positions.
/// </summary>
private void RecalculateSizes()
    if (this.button_GB.Top < this.rounded_button_RB.Bottom)
        this.button_GB.Top = this.rounded_button_RB.Bottom;
        this.border_GB.Top = this.button_GB.Bottom + 5;
    if (this.Height < this.border_GB.Bottom + 100)
        this.Height = this.border_GB.Bottom + 100;

I also added a button to allow scaling of the form for users with high resolution monitors. The way this works is surprisingly simple, unlike most complicated / not working suggestions that I found when searching the internet.

Note that the AutoScaleMode property of the form must be set to the default, Font, for this to work:

private void Button_Click(object sender, EventArgs e)
    Button button = (Button)sender;
    string tag = button.Tag.ToString().ToUpper().Trim();
    switch (tag)
        case "ENLARGE":
            // Scale form, AutoScaleMode.Font must be set for this to work.
            this.Font = new Font(this.Font.Name, this.Font.Size + 2);

A word of warning: This scaling method works well with most controls, but not with complicated controls like FlowLayoutPanel.

I also added new properties:

  • RotatedText
  • RotatedTextAngle

These allow to rotate text in degrees, typically -90 or 90 degrees for vertically orientated text.

Using the Code

Don't forget to set RoundedButtonDialog as the startup project after loading the solution.


  • v 1.2
    • Fixed wrong size when changing width or height, button was too big
    • Fixed missing bottom and right side lines with thickness 1
  • V 1.3
    • Improved the drawing routine DrawBorderGraphic()


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Netherlands Netherlands
Software developer in the Netherlands, currently working on Video Surveillance applications.
Experience: C#, C++, VB, ASP, SQL Server, PostgreSQL.
It all started with Black&White, no not the whiskey but the Sinclair ZX81 followed by several Atari's and PC's. The journey continues ...

You may also be interested in...

Comments and Discussions

QuestionNice, but number of pixels in the border not consistent Pin
Member 1150234821-Jan-18 1:00
memberMember 1150234821-Jan-18 1:00 
AnswerRe: Nice, but number of pixels in the border not consistent Pin
RickZeeland21-Jan-18 9:51
mveRickZeeland21-Jan-18 9:51 
GeneralRe: Nice, but number of pixels in the border not consistent Pin
Member 1150234821-Jan-18 11:48
memberMember 1150234821-Jan-18 11:48 
GeneralRe: Nice, but number of pixels in the border not consistent Pin
Member 1150234822-Jan-18 4:43
memberMember 1150234822-Jan-18 4:43 
GeneralRe: Nice, but number of pixels in the border not consistent Pin
RickZeeland23-Jan-18 9:06
mveRickZeeland23-Jan-18 9:06 
BugButton size too big Pin
RickZeeland20-Jan-18 22:22
mveRickZeeland20-Jan-18 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190214.1 | Last Updated 21 Jan 2018
Article Copyright 2018 by RickZeeland
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid