Toggle Button in .NET

0.00 avg. rating (0% score) - 0 votes

Ever wondered how to create a button which toggles it’s state in C# windows Forms? It used to exist in VB6 / Office development as a ToggleButton, but cannot easily be found in C#

It turns out you need to use the System.Windows.Forms.Checkbox control but set its Appearance property to ‘Button’. Usually you would just set this in the IDE but alternatively heres the code …


CheckBox checkBox1 = new System.Windows.Forms.CheckBox();
checkBox1
.Appearance = System.Windows.Forms.Appearance.Button;

0.00 avg. rating (0% score) - 0 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>