Click here to Skip to main content
13,000,179 members (52,605 online)
Click here to Skip to main content
Add your own
alternative version


7 bookmarked
Posted 3 Apr 2013

Sizable Glyph for CheckBox/RadioBox Control - WinForms

, 4 Apr 2013
Rate this:
Please Sign up or sign in to vote.
This article will show you how to use the Sizable CheckBox control I have designed.


I begun noticing a trend of people asking for checkbox where the glyph can be sized just like the font instead of staying to the set size of 13 x 13. So what did I do? I went and created my own control that acts almost exactly like a checkbox... except you can scale/edit the size of the glyph!

After further reflection, I have also added a Radio Button Mode to the control. It acts just like any other radio button and can be grouped in containers.


Things to know before starting:

  • Your application must be set to compile as .NET Framework 4 (not .NET Framework 4 ClientProfile which is the default!) Go to Project Settings > Compile > Advanced Compile Options > Target Framework
  • The word wrap option doesn't always work as expected, words can get cut off
  • I haven't added a tri-state check yet to it.
  • Auto-size is set to false and cannot be changed. I'm not sure I'll implement this.

Version Change


  • Changed Radiobutton mode to not allow de-selecting selected radio button

Using the Code

The control for the most part works just like a regular checkbox.

See the attached project for an example of the majority of my added properties. It also contains the compiled .dll to just drop into your project.

There is one additional function I have added since it was a little pet-peeve of mine.

'Create a new bettercheckbox and toggle it
Dim BetterCB as New BetterCheckBox
BetterCB.Text = "Hello World!"

Paste that function in any event you wish and it will create a new BetterCheckbox and toggle it to true.

Obviously, there are dozens of other properties you can set first.

To see it in action, download the example project from above and compile/run.


Added Functions


Toggle the state of the Checkbox (or radiobutton) between True and False.

Added Properties


Get or set the alignment of the glyph within the control AS:

Public Enum CBAlignment
       TopLeft = 1
       TopCenter = 2
       TopRight = 4
       MiddleLeft = 16
       MiddleCenter = 32
       MiddleRight = 64
       BottomLeft = 256
       BottomCenter = 512
       BottomRight = 1024
   End Enum


Get or set the style of the glyph border AS.

Public Enum CBBorderStyle
       Flat = 1
       Sunken = 0
   End Enum


Get or set the Glyph Mark color AS COLOR.

*Note: Rather than use a flat color, I do add a slight linear gradient to the check, barely discernible but I believe it adds a little extra to it.


Get or set the Glyph Drawing Style AS.

Public Enum CBGlyphStyle
       CheckMark = 0
       X_Mark = 1
       Circle = 2
       Square = 3
       Diamond = 4
       FourPointedStar = 5
       FivePointedStar = 6
       SixPointedStar = 7
       StarBurst = 17
       StarOfDavid = 8
       HappyFace = 9
       StraightFace = 10
       FrownyFace = 11
       SkullCrossBones = 12
       RainDrop = 13
       YingYang = 14
       Clock = 15
       Bomb = 16
   End Enum


Gets or set the height of the Checkbox Glyph in pixels AS INTEGER.

*Note: There is a minimum of 15 for the manual method. And this property only has an effect if CheckBoxSizeMode is set to CBSizeMode.Manual.


Gets or Sets how the glyph is sized within the control AS.

Public Enum CBSizeMode
       ScaleToFont = 0
       ScaleToControl = 1
       Manual = 2
       MSDefault = 3
End Enum
  • ScaleToFont will scale the glyph as the font size changes *See CheckBoxSizeScaleRatio.
  • Manual will scale the glyph based on CheckBoxManualSize.
  • ScaleToControl will set the Glyph height to be the same as the control height - Margins.
  • MSDefault will set the Glyph to the Default of 15.


Gets or sets the Scale Ratio of Glyph Size to Font size AS DOUBLE.


Gets or sets the Mode the Checkbox is currently running in AS.

Public Enum CBMode
       CheckBox = 0
       RadioButton = 1
   End Enum

If the Checkbox is in RadioButton mode, it can be placed inside a container control to group them as normal.


Gets or sets the placement of the text within the control AS.

Public Enum CBAlignment
       TopLeft = 1
       TopCenter = 2
       TopRight = 4
       MiddleLeft = 16
       MiddleCenter = 32
       MiddleRight = 64
       BottomLeft = 256
       BottomCenter = 512
       BottomRight = 1024
   End Enum

*Note: If the glyph and text alignment are the same, the text will move so as not to cover the glyph. The text can still cover the glyph if the box is too small and the alignment is set to different locations.


Gets or sets whether text will wrap in the control if it is too long to fit AS BOOLEAN.

*Note: This does not always work as expected and can cut words off. Try editing the size of the control if this happens.


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


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 4 Apr 2013
Article Copyright 2013 by psychohamster
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid