Child Controls in RibbonBar

8 posts, 0 answers
  1. Robert
    Robert avatar
    2 posts
    Member since:
    Dec 2010

    Posted 02 Dec 2010 Link to this post

    Hi There,

    I am very new to Telerik winform controls and trying to use RadRibbonBar and would like to get all the child elements (i.e. start menu items, buttons, group boxes etc) from the ribbon bar in a control collection. I want to enable and disable the specific controls based on user rights.

    Please let me know if there is any possibility to get around that.

    Cheers,

    Robert
  2. Nabeel
    Nabeel avatar
    3 posts
    Member since:
    Nov 2010

    Posted 06 Dec 2010 Link to this post

    I'm also looking for same answer, how to get all child elements directly to enable or disable as per requirements.? and would request Telerik team to support ASAP...
  3. UI for WinForms is Visual Studio 2017 Ready
  4. aquariens
    aquariens avatar
    8 posts
    Member since:
    Jun 2009

    Posted 07 Dec 2010 Link to this post

    Looking for similar scenario, hope to hear soon.

    Shahzad
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 07 Dec 2010 Link to this post

    Hi Robert,

    Thank you for writing.

    You could access the design-time created items directly as shown below:

    this.radButtonElement1.Enable = false;

    Or, you can access an item via Group Items collection:
    radRibbonBarGroup1.Items[0].Enabled = false;

    Also, you can add and access the elements in RadRibbonBar's menu:
    RadMenuItem mnuPrint = new RadMenuItem("Print");
    radRibbonBar1.StartMenuItems.Add(mnuPrint);

    For additional information, please follow the help topic Programming RadRibbonBar.

    I hope this helps. Do not hesitate to contact us if you have other questions.

    Kind regards,
    Peter
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  6. Robert
    Robert avatar
    2 posts
    Member since:
    Dec 2010

    Posted 07 Dec 2010 Link to this post

    Hi Peter,

    Many thanks for your reply, however, this is not what I wanted. Please refer to the following psudoe code to get the idea what I would like to have.

    Dim ctlCol As Collection

    For Each ctl As Control In RadRibbonBar
        ctlCol.Add(ctl)
    Next

    I would like to have all of the controls or elements in a collection of RadRibbonBar at runtime not design time. Where I can enable or disable these controls according to the rights a user have.

    Please help,
    Many thanks,

    Robert
  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 10 Dec 2010 Link to this post

    Hi Robert,

    Thank you for writing back.

    Our controls are build on top on TPF (Telerik Presentation Framework) and use elements, not controls. Controls in the RadControls for WinForms suite have both a general shared architecture and a specific internal structure.

    • All controls have access to common services provided by TPF such as theming, animation, and property binding.
    • No matter how complex a control may be, a control is built up from a few simple types of elements. By working with these elements, you can customize any control on a very granular level.
    • All elements in a control element tree inherit common property values from their parent elements unless these values are set locally. This feature helps each element to use less memory while still providing fine-grained customization options.

    You could enumerate all elements (not controls) in RadRibbonBar with follow line of code:
    For Each element As RadElement In RadRibbonBar.RootElement.ChildrenHierarchy
        elementCol.Add(element)
    Next

    I strongly recommend reading the following help topic about the internal structure of RadRibbonBar -Programming RadRibbonBar.

    I hope this helps.

    Greetings,
    Peter
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  8. Robert Kozar
    Robert Kozar avatar
    3 posts
    Member since:
    Apr 2005

    Posted 12 Mar 2013 Link to this post

    This is how i get the item i am looking for... (maybe there is a better way?) other then declaring the element in the designer - my app allows people to add/remove items with logic so being able to locate controls/elements is key without hardcoded declarations or custom collections.
    private RadElement GetRibbonBarItemByName(string name)
    {
         var radCol = MainConsole.ribbonBar.RootElement.ChildrenHierarchy.Where(o => o.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
         if (radCol.Count() > 0)
              return radCol.Single();
         else
              return null;
    }

     

     

     

     

  9. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 14 Mar 2013 Link to this post

    Hi Robert,

    Thank you for contacting us. 
    I can confirm that this approach is correct and you can use it. 

    Should you have any other questions or suggestions, do not hesitate to contact us.

    Regards,
    Peter
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top
UI for WinForms is Visual Studio 2017 Ready