This is a migrated thread and some comments may be shown as answers.

RadMenu Items Find

1 Answer 182 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Tim Larson
Top achievements
Rank 1
Tim Larson asked on 12 Jun 2019, 07:06 PM

Hi,

I am using the RadMenu and my menu is dynamically created using a database.  The user can select a default start up form and I need to search though the menuitems with recursion to find that startup item and then perform the click event on that menu item.

In the windows menu I was able to do this this.mainMenu.Items.Find(reportID, true).  How can I do this on the menu items?

Thanks,

Tim

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 14 Jun 2019, 01:00 PM
Hello Tim,

There is no method to do this in RadMenu, but you can manually implement it on your own. Here is a sample implementation of finding RadMenuItem recursively:
private void radButton1_Click(object sender, EventArgs e)
{
    RadMenuItem found = FindItem("radMenuItem12", radMenuItem1);
 
    if (found != null)
    {
        Console.WriteLine(found.Text);
    }
}
public RadMenuItem FindItem(string text, RadMenuItem mainItem)
{
    if (mainItem.Text == text)
    {
        return mainItem;
    }
 
    foreach (RadMenuItem item in mainItem.Items)
    {
        var result = FindItem(text, item);
 
        if (result != null)
        {
            return result;
        }
    }
     
    return null;
}

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Menu
Asked by
Tim Larson
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or