Tuesday, August 11, 2009

Custom ToolStrip Controls

Use the below code to create a ToolStrip host which enable to make any custom control to be used in the toolstrip bar


using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms.Design;
using System.Windows.Forms;

namespace My.Controls
{
[System.ComponentModel.DesignerCategory("code")]
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
public class ComboToolStripControlHost : ToolStripControlHost
{

static ToolStripComboExt m_combo = new ToolStripComboExt();

public ComboToolStripControlHost()
: base(CreateControlInstance())
{
}

private static Control CreateControlInstance()
{
return m_combo;
}

public ToolStripComboExt TSCombo
{
get { return m_combo; }
}
}
}

No comments: