fguihen Posted March 30, 2007 Posted March 30, 2007 Ive done a small tutorial online and created what i think is a checkbox that can be used on a toolstrip. the problem is i dont know how to add it to the tool strip. can anybody advise where to add this, and what code to use to add it. my ToolStripCheckBox code is shown below: class ToolStripCheckBox:System.Windows.Forms.ToolStripControlHost { public ToolStripCheckBox() :base (new System.Windows.Forms.CheckBox()) { } public CheckBox ToolStripCheckBoxControl { get { return Control as CheckBox; } } //expose checkbox.enabled as property public bool ToolStripCheckBoxEnabled { get { return ToolStripCheckBoxControl.Enabled; } set { ToolStripCheckBoxControl.Enabled = value; } } protected override void OnSubscribeControlEvents(Control c) { // Call the base method so the basic events are unsubscribed. base.OnSubscribeControlEvents(c); CheckBox ToolStripCheckBoxControl = (CheckBox)c; // Remove the event. ToolStripCheckBoxControl.CheckedChanged += new EventHandler(CheckedChanged); } protected override void OnUnsubscribeControlEvents(Control c) { // Call the base method so the basic events are unsubscribed. base.OnUnsubscribeControlEvents(c); CheckBox ToolStripCheckBoxControl = (CheckBox)c; // Remove the event. ToolStripCheckBoxControl.CheckedChanged -= new EventHandler(CheckedChanged); } public event EventHandler CheckedChanged; private void OnCheckChanged(object sender, DateRangeEventArgs e) { if (CheckedChanged != null) { CheckedChanged(this, e); } } } Quote
Leaders snarfblam Posted March 30, 2007 Leaders Posted March 30, 2007 Not having any experience writing tool strip controls, all I can offer is this one idea: You might want to use a tool such as Reflector to examine the ToolStrip controls designed by Microsoft. There may be a combination of attributes required in order for a ToolStripControl to be displayed in the list. For a quick and dirty approach, add a ToolStripButton to the tool strip, and change the control's type in the designer-generated code. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.