How to find which method calls in click event when program running

204 Views Asked by At

I have devcomponent dotnetbar sidebar in my form and I tried to add menu strip items to it with a command. It works, but I need to add a click event of each submenu to sidebar buttons click event.

private void InitMenu()
{
    DevComponents.DotNetBar.BaseItem[] baseitem = new DevComponents.DotNetBar.BaseItem[menuStrip.Items.Count];
    System.Windows.Forms.ToolStripMenuItem submenuitem = new System.Windows.Forms.ToolStripMenuItem();
    for (int ii = 0; ii < menuStrip.Items.Count; ii++)
    {
        try
        {
            baseitem[ii] = new DevComponents.DotNetBar.SideBarPanelItem();
            baseitem[ii].Name = menuStrip.Items[ii].Name.ToString();
            baseitem[ii].Text = menuStrip.Items[ii].Text.ToString();
            submenuitem = (ToolStripMenuItem)menuStrip.Items[ii];
            DevComponents.DotNetBar.ButtonItem[] buttonitem = new DevComponents.DotNetBar.ButtonItem[submenuitem.DropDownItems.Count];

            for (int i = 0; i < submenuitem.DropDownItems.Count; i++)
            {
                if (submenuitem.DropDownItems[i].Text == "" || submenuitem.DropDownItems[i].Text.Trim() == "-") { continue; }

                DevComponents.DotNetBar.ButtonItem blnitem = new DevComponents.DotNetBar.ButtonItem(submenuitem.DropDownItems[i].Name, submenuitem.DropDownItems[i].Text);
                blnitem.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
                blnitem.ImagePaddingHorizontal = 8;
                blnitem.Click += new EventHandler(submenuitem.DropDownItems[i].Click); // how to bind the relative menu event to blnitem?
                blnitem.ImagePosition = DevComponents.DotNetBar.eImagePosition.Top;
                baseitem[ii].SubItems.Add(blnitem);
            }

            sideBar1.Panels.Add(baseitem[ii]);
            sideBar1.Refresh();
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
}
0

There are 0 best solutions below