Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I have a toolstrip and i want to add a checkbox to it,but Idont know how to do it.
please help me.
Posted 28-Apr-10 20:32pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

in form load event:
            CheckBox cb = new CheckBox();
            cb.Text = "test";
            cb.CheckStateChanged += (s, ex) => this.Text = cb.CheckState.ToString();
            ToolStripControlHost host = new ToolStripControlHost(cb);
            toolStrip1.Items.Insert(0,host);
[edit]Inline code changed to Code block: it preserves the formatting- OriginalGriff[/edit]
  Permalink  
v2
Comments
Pablo Aliskevicius at 26-Aug-12 3:39am
   
My 5!
Also:

cb.BackColor = Color.Transparent; // to show the toolstrip background.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Don't use a CheckBox for this purpose.
On a ToolStrip you are supposed to use a ToolStripButton which has the same functionality as a CheckBox. Just use its Checked property!
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 5 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100