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

Child Controls in RibbonBar

7 Answers 244 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 02 Dec 2010, 04:56 PM
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

7 Answers, 1 is accepted

Sort by
0
Nabeel
Top achievements
Rank 1
answered on 06 Dec 2010, 05:51 PM
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...
0
aquariens
Top achievements
Rank 1
answered on 07 Dec 2010, 07:22 AM
Looking for similar scenario, hope to hear soon.

Shahzad
0
Peter
Telerik team
answered on 07 Dec 2010, 02:13 PM
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.
0
Robert
Top achievements
Rank 1
answered on 07 Dec 2010, 03:50 PM
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
0
Peter
Telerik team
answered on 10 Dec 2010, 05:36 PM
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.
0
Robert Kozar
Top achievements
Rank 1
answered on 13 Mar 2013, 02:35 AM
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;
}

 

 

 

 

0
Peter
Telerik team
answered on 14 Mar 2013, 02:38 PM
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.
Tags
RibbonBar
Asked by
Robert
Top achievements
Rank 1
Answers by
Nabeel
Top achievements
Rank 1
aquariens
Top achievements
Rank 1
Peter
Telerik team
Robert
Top achievements
Rank 1
Robert Kozar
Top achievements
Rank 1
Share this question
or