dynamic from database

22 posts, 0 answers
  1. Kevin Duncan
    Kevin Duncan avatar
    1 posts
    Member since:
    Jan 2004

    Posted 25 Sep 2007 Link to this post

    are there any samples on how to build a menu dynamically from the database?
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 25 Sep 2007 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. jerry
    jerry avatar
    103 posts
    Member since:
    Feb 2008

    Posted 06 May 2009 Link to this post

    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.


  5. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 06 May 2009 Link to this post

    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
  6. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 07 May 2009 Link to this post

    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.
  7. jerry
    jerry avatar
    103 posts
    Member since:
    Feb 2008

    Posted 07 May 2009 Link to this post

    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
  8. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    Glad I could help

    Gerbrand
  9. jerry
    jerry avatar
    103 posts
    Member since:
    Feb 2008

    Posted 07 May 2009 Link to this post

    Sorry I had to edit my previous post with my issue after I got it  working.
  10. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    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.







  11. jerry
    jerry avatar
    103 posts
    Member since:
    Feb 2008

    Posted 07 May 2009 Link to this post

    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
  12. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    I don't mind :-)

    Always happy to help somebody


  13. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    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
  14. jerry
    jerry avatar
    103 posts
    Member since:
    Feb 2008

    Posted 08 May 2009 Link to this post

    gerbran,
    Thank you so much for all the help it is truely appreciated.


    Jerry
  15. Christopher Roberts
    Christopher Roberts avatar
    2 posts
    Member since:
    Nov 2009

    Posted 16 Nov 2009 Link to this post

    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 !
  16. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 17 Nov 2009 Link to this post

    Hi christopher,

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

    If you have more questions, let me know.

    Gerbrand
  17. Christopher Roberts
    Christopher Roberts avatar
    2 posts
    Member since:
    Nov 2009

    Posted 17 Nov 2009 Link to this post

    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
  18. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 20 Nov 2009 Link to this post

    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.
  19. Manesh
    Manesh avatar
    24 posts
    Member since:
    Feb 2012

    Posted 08 Aug 2012 Link to this post

    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
  20. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Aug 2012 Link to this post

    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 >>
  21. RJ
    RJ avatar
    386 posts
    Member since:
    Oct 2006

    Posted 01 Nov 2012 Link to this post

    Any chance that this new version of radmenu can be populated dynamically thru database or xml just like in web?
  22. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Nov 2012 Link to this post

    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.
  23. RJ
    RJ avatar
    386 posts
    Member since:
    Oct 2006

    Posted 05 Nov 2012 Link to this post

    Thanks Stefan
Back to Top
UI for WinForms is Visual Studio 2017 Ready