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:
Code:
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);
}
}
}