The user can initialize a toolstripitem very easily with LinsUI Layout Manager 2.1.
The following example demonstrates how to specify and code the handler for the INITIALIZE event of a Dropdown control
First define a unique ID for m_nColorsDropDownID in LinsResource class as following,
using LinsUI;
public static class LinsResource
{
// The Category name
[CommandGroupNameAttribute("Colors"),
// Tell the application, it is a dropdown button
CommandTypeAttribute(TSITEM_TYPEID.DROPDOWNBUTTON),
// Tooltip for the menu item
ToolTipAttribute("Select a color"),
// The detail description
DetailDescriptionAttribute("Select a color for the selected shapes.")]
public const long m_nColorsDropDownID = FlexConstants.m_nUserDefinedControlStartID + 5;
}
Then assign the unique ID to the tag of the menu item, and define the handler function for the INITIALIZE event as following,
public partial class ColorsMenu : LinsUI.LinsMenuStrip
{
private ToolStripMenuItem m_Colors;
public ColorsMenu()
{
InitializeComponent();
m_Colors = new ToolStripMenuItem();
// Assign an unique ID to the m_Colors menu dropdown item
m_Colors.Tag = LinsResource.m_nColorsDropDownID;
}
// define the handler function for the INITIALIZE event
// when the Color dropdown is created, this event will be fired and only fired once.
// The user can use this event to do initialization
[CommandIDAttribute(LinsResource.m_nColorsDropDownID),
// The event type, here is an initialize event
CommandEventAttribute(CUSTOM_TI_EVENT.INITIALIZE)]
void ColorsInitialize(object sender, System.EventArgs e)
{
// Add all possible colors into the Color dropdown list
foreach (Color_Name pair in DemoManager.m_lsColorName)
{
this.m_Colors.DropDownItems.Add(pair.m_csName);
}
}
No comments:
Post a Comment