0

You know, after clicking on RadMenuItem, submenus are opening. But this not effective for me. I want that, when onmouseover event, submenus are opened automatically. Norally in winforms below codes realize my wish:

private void menuStrip_MouseEnter(object sender, EventArgs e)
{
    var menu = (ToolStripMenuItem)sender;
    menu.ShowDropDown();
}

Could you help me, how do I this in RadMenu?

EDIT: I tried like this:

private void rmiAna_MouseEnter(object sender, EventArgs e)
{
    var menu = (RadMenu)sender;
    menu.IsSubmenuOpen = true;
}

When I tried above codes, I got error like this: enter image description here

Could you help me? Kind regards.

  • If I clearly understand, you need IsSubmenuOpen property. – Spawn Nov 28 '15 at 20:18
  • @Spawn, Firstly thank you. When I bring cursor over the menu, submenus must open automatically without need to click. But when I tired this code: `var menu = (RadMenu)sender;` `menu.IsSubmenuOpen();` is not a valid property. –  Nov 28 '15 at 20:31
  • IsSubmenuOpen - property, not method, so we writing menu.IsSubmenuOpen = true; – Spawn Nov 28 '15 at 20:37
  • @Spawn, I edit my question, When I tired as you said, I got error. Thank you. –  Nov 28 '15 at 21:24
  • WinForms.... My fault, sorry. As i understand it will be ShowChildItems() method... – Spawn Nov 28 '15 at 21:34
  • You're welcome. Thank you for your interest. –  Nov 28 '15 at 21:50
  • If you are using Telerik UI for WinForms, you don't have to do anything to show the submenu items. Simply placing the mouse in the menu will open the child elements. Here is a small video I captured for you: http://screencast.com/t/JXgemcZsoyRY. – checho Nov 30 '15 at 09:47
  • @checho, But first time, when you carried cursor on "Item 0", submenu did not open automatically. You clicked on time, then menu was activated and after this, menu items and sub-items opened onmouseover event. Idon't want to the this. I want to open sub-menu while onmouseover event. –  Dec 01 '15 at 20:46

1 Answers1

0

To show the sub menu items of root items, you can iterate all menu items and subscribe to the MouseEnter event of the root ones. In the handler, call the following method:

    private void radButton1_Click(object sender, EventArgs e)
    {
        IterateItems(radMenu1.Items);
    }

    void IterateItems(RadItemOwnerCollection items)
    {
        foreach (RadMenuItemBase item in items)
        {
            if (item.IsRootItem)
            {
                item.MouseEnter += item_MouseEnter;
            }

            if (item.HasChildItemsToShow)
            {
                IterateItems(item.Items);
            }
        }
    }

    void item_MouseEnter(object sender, EventArgs e)
    {
        RadMenuItem hoveredItem = (RadMenuItem)sender;
        hoveredItem.DropDown.Show();
    }
checho
  • 3,092
  • 3
  • 18
  • 30