user1645200
user1645200

Reputation: 145

Tri State Chech box for ToolStripDropDownButton

I have statusbar strip with ToolStripMenuItems. I need to gruop the Toolstrip menu items and Implement TriStateCheckbox functionality,

  1. Is it Possible to Create checkbox with ToolStripMenitems?
  2. If its not Possible for Point 1, then How to Add TreeView to StatusStrip. enter image description here

Upvotes: 1

Views: 531

Answers (1)

Reza Aghaei
Reza Aghaei

Reputation: 125197

To have a three-state menu item, you can set CheckState of each ToolStripMenuItem to Indeterminate, Checked or Unchecked.

enter image description here

Also if you want to use a tree-view control (which doesn't have builtin support for three-state check boxes) or something like this control, you should know, you can host any control in drop-down using ToolStripControlHost. For example, here is a ToolStripTreeView control:

using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class ToolStripTreeView : ToolStripControlHost
{
    [DesignerSerializationVisibility( DesignerSerializationVisibility.Content)]
    public TreeView TreeViewControl { get { return (TreeView)Control; } }
    public ToolStripTreeView() : base(CreateControl()) { }
    private static TreeView CreateControl()
    {
        var t = new TreeView();
        return t;
    }
}

enter image description here

Upvotes: 1

Related Questions