Unifosys > Unifosys Support Help Desk > Knowledgebase

Ask a question:

Dynamic Menu - Create Chart Menu at Run-time


Dynamic Menu - Create Chart Menu at Run-time

Question: How can I create a menu for organization chart at run-time?

Answer: You can create menu at run-time, by accessing the ToolStripItemCollection of hpMenu4Chart property.

Add Menu Items & Event Handler

Add menu items with a name & assign event handler:
Snippet        private void frmMain_Load(object sender, System.EventArgs e)
            hierarchyWin1.hpMenu4Chart.AvailableOnChart = true;//display
            ToolStripItemCollection items = hierarchyWin1.hpMenu4Chart.Items;//get a reference
            ToolStripItem tsi = items.Add("Item 1", Properties.Resources.huser/*image*/, MenuItem_Click);//add one item
            tsi.Name = "action1";
            tsi = items.Add("Item 2", Properties.Resources.huser/*image*/, MenuItem_Click);//add another item
            tsi.Name = "action2";
            //similarly add more items
        void MenuItem_Click(object sender, EventArgs e)
            //identify the clicked action
            ToolStripItem tsi = sender as ToolStripItem;
            MessageBox.Show(tsi.Text + ": " + tsi.Name);

Add Menu Items From Designer

NOTE: You can add items to hpMenu4Chart, directly from form designer.
Was this article helpful? yes / no
Article details
Article ID: 21
Category: Support Questions
Date added: 16-Sep-2014
Views: 215
Rating (Votes): Article not rated yet (0)

<< Go back

© 2013

Powered by Help Desk Software HESK™