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

dynamic from database

23 Answers 435 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Kevin Duncan
Top achievements
Rank 1
Kevin Duncan asked on 25 Sep 2007, 06:32 AM
are there any samples on how to build a menu dynamically from the database?

23 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 25 Sep 2007, 09:43 AM
Hello Kevin Duncan,

If you think of automatic binding to hierarchical data sources, currently RadMenu does not support this feature. This is on our list of new features, waiting for implementation.

There is still the possibility to create and initialize RadMenu dynamically at runtime with data produced from some database. Here is a sample how to create a RadMenu dynamically:

RadMenu menu = new RadMenu(); 
menu.BeginInit(); 
 
menu.Items.Add(new RadMenuItem("Item 1")); 
menu.Items.Add(new RadMenuItem("Item 2")); 
menu.Items.Add(new RadMenuItem("Item 3")); 
 
RadMenuItem item1 = (RadMenuItem)menu.Items[0]; 
item1.Items.Add(new RadMenuItem("Sub menu item 1")); 
item1.Items.Add(new RadMenuItem("Sub menu item 2")); 
 
((RadMenuItem)item1.Items[0]).Click += new EventHandler(item1_Click); 
            
menu.EndInit(); 
 
this.Controls.Add(menu); 


We did a little research and didn't find other controls for WinForms that support data binding. Do you have experience with such a suite? We will be glad to review it if you can provide us with more information on your case.

 
Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
jerry
Top achievements
Rank 1
answered on 06 May 2009, 04:32 PM
Jack,
How can I use a loop to populate my menu?  I don't know how many items there are so I can't define the number of RadMenuItems.
How can I use a database to create a list that has years in it that when selected will open a side menu off of that year that will show some studies based on that year?

Menu
2009 > T09_1 > B1_1
                          B1_2
            T09_2 >
                          B2_1
            T09_3 >
                          B3_1
                          B3_2

2008 > T08_1 > B1_1
2007 > T07_1 > B1_1

I can create 1 query to bring back all this info then I need to find a way to add the menu item then the children menus.


0
gerbrand
Top achievements
Rank 2
answered on 06 May 2009, 10:08 PM
Hi Jerry,

Once again you can find a sample on my weblog. I updated the little project. I added a radmenu that loads the things you said.
I hope that this will help you to a solution.

Gerbrand
0
Jack
Telerik team
answered on 07 May 2009, 12:53 PM
Gerbrand, thank you for your enthusiasm and for sharing your solutions with the community.

Jerry, you could use the code from Gerbrand's weblog. If this doesn't help, please give us more details and I will try to find a proper solution.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 07 May 2009, 03:23 PM
Gerbrand,
Man that was perfect. 
I just ran into an issue after getting it working.
Is there a way to make an event for the article menu item? When the user clicks this I need to query the DB using all three menu options(Year, Study, Article). 

You need to write a telerik book. 

Thanks for the help again
Jerry
0
gerbrand
Top achievements
Rank 2
answered on 07 May 2009, 03:24 PM
Glad I could help

Gerbrand
0
jerry
Top achievements
Rank 1
answered on 07 May 2009, 03:30 PM
Sorry I had to edit my previous post with my issue after I got it  working.
0
gerbrand
Top achievements
Rank 2
answered on 07 May 2009, 03:33 PM
Yep you can add a event to the menu
See Jacks post:

((RadMenuItem)item1.Items[0]).Click += new EventHandler(item1_Click);

If I'm home I will add it to the little project.







0
jerry
Top achievements
Rank 1
answered on 07 May 2009, 03:51 PM
Gerbrand,
Thank you for the help I will dig into it more.  Please don't spend too much time on it I hate to bother you anymore.

Thank You for pointing me in the right direction

Jerry
0
gerbrand
Top achievements
Rank 2
answered on 07 May 2009, 03:58 PM
I don't mind :-)

Always happy to help somebody


0
gerbrand
Top achievements
Rank 2
answered on 07 May 2009, 09:35 PM
Hi Jerry,

If you go to my weblog you can find an update of the little project. I added an eventhandler on the Article rad menu items. When clicked on one of those items a message box appear that says which item is clicked and what the parent items are. so I think you can use this.

Let me know if you have further questions.

gerbrand
0
jerry
Top achievements
Rank 1
answered on 08 May 2009, 01:05 PM
gerbran,
Thank you so much for all the help it is truely appreciated.


Jerry
0
Christopher Roberts
Top achievements
Rank 1
answered on 17 Nov 2009, 04:17 AM
Gerbrand,

   I am trying to accomplish this also. I looked on your blog and am unable to find the code you mention. Could you repost it please ?


Thank You,

Christopher

Telerik Noob !
0
gerbrand
Top achievements
Rank 2
answered on 17 Nov 2009, 08:51 AM
Hi christopher,

You can find the code in this project.
Hope it helps you.

If you have more questions, let me know.

Gerbrand
0
Christopher Roberts
Top achievements
Rank 1
answered on 17 Nov 2009, 01:05 PM
Gerbrand,

  After looking at it I realized  missed the the fine print.... The part about it containing Jerry's Menu.


Thank You again...

This should help move me in the correct direction...


Christopher
0
Nikolay
Telerik team
answered on 20 Nov 2009, 03:16 PM
Hello gerbrand,

Your Telerik points have just been updated for your community effort.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Manesh
Top achievements
Rank 2
answered on 09 Aug 2012, 04:52 AM
Hi, one and all,

 I've created a rad menu programatically and i've assigned short cuts for each item, but i've unable to travese through the menu items from the key board and error is show in the image, means i've pressed ALT + V to open a menu item and after that i presssed alt + q but still the focus is on the ALT + V only please help me out
0
Stefan
Telerik team
answered on 13 Aug 2012, 11:10 AM
Hi Manesh,

Thank you for writing.

The experienced behavior is the desired behavior. The mnemonics are activated only for open menus. Once you press Alt + V the menu for the Validation and Checks menu item is opened and the mnemonics will work only for its menu items, while you are trying to start a mnemonic of a main menu item. The behavior is the same with the standard menu and since we are trying to be consistent with the standard controls, it is the same in our suite.

As an alternative, I can suggest using RadShortcut for your scenario. Here is a small sample:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        this.radMenuItem1.Shortcuts.Add(new RadShortcut(Keys.Control, Keys.D));
        this.radMenuItem2.Shortcuts.Add(new RadShortcut(Keys.Control, Keys.R));
 
        radMenuItem1.Click += new EventHandler(radMenuItem1_Click);
        radMenuItem2.Click += new EventHandler(radMenuItem1_Click);
    }
 
    void radMenuItem1_Click(object sender, EventArgs e)
    {
        foreach (RadMenuItem item in radMenu1.Items)
        {
            item.HideChildItems();
        }
        (sender as RadMenuItem).ShowChildItems();
    }
}

More information regarding RadShortcut can be found here: http://www.telerik.com/help/winforms/shortcuts-getting-started-(radmenuitems).html.

Off topic, this forum thread concerns a topic of different matter. Please avoid posting question in threads that are not related to it. If you cannot find the correct thread, you can always open a new one.

Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
RJ
Top achievements
Rank 1
answered on 01 Nov 2012, 10:50 AM
Any chance that this new version of radmenu can be populated dynamically thru database or xml just like in web?
0
Stefan
Telerik team
answered on 05 Nov 2012, 04:29 PM
Hi RJ,

Currently, we have no plans on implementing such a functionalities. However, I will add feature requests in our Public Issue Tracking System, so you guys can vote for them. Once the requests gather enough votes, we will consider their implementation. Feel free to add your vote/subscribe for status updates here:
I hope this helps.

Regards,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
RJ
Top achievements
Rank 1
answered on 05 Nov 2012, 10:13 PM
Thanks Stefan
0
solehhudin
Top achievements
Rank 1
answered on 19 Jul 2017, 10:21 AM
DOWNLOAD FULL PROJECT https://drive.google.com/file/d/0B55z6hBNJXFEbklpWWlXOVJsbkk/view
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Jul 2017, 11:47 AM
Hello , 

Thank you for writing.  

Do you have any question related to RadMenu from the Telerik UI for WinForms suite? If you are experiencing any problem with using RadMenu feel free to submit a support ticket providing additional information and a sample project. Thus, our support engineers will gladly assist you.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Menu
Asked by
Kevin Duncan
Top achievements
Rank 1
Answers by
Jack
Telerik team
jerry
Top achievements
Rank 1
gerbrand
Top achievements
Rank 2
Christopher Roberts
Top achievements
Rank 1
Nikolay
Telerik team
Manesh
Top achievements
Rank 2
Stefan
Telerik team
RJ
Top achievements
Rank 1
solehhudin
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or