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

Loop through all elements in a radRibbonBar

1 Answer 144 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
Veteran
James asked on 28 Dec 2020, 09:09 PM

I need to loop through all controls/elements and child controls/elements on a form and disable the control/element if the Tag property = "someText".

The following code works for controls and child controls on the form, but not for radRibbonBar elements. 

=================================================
foreach (var control in GetControlHierarchy(this))
            {
                if (control.Tag != null)
                {
                    if (control.Tag.Equals("someText"))
                    {
                        control.Enabled = false;
                    }
                }
            }

 private IEnumerable<Control> GetControlHierarchy(Control root)
        {
            var queue = new Queue<Control>();

            queue.Enqueue(root);

            do
            {
                var control = queue.Dequeue();

                yield return control;

                foreach (var child in control.Controls.OfType<Control>())
                    queue.Enqueue(child);

            } while (queue.Count > 0);
        }
======================================================

How would I change the above code to include radRibbonBar elements?

Thank you,

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 29 Dec 2020, 11:21 AM

Hello, James,

RadRibbonBar is a complex control. Its elements are organized in groups. You can refer to the structure article for better understanding. If you want to loop through all the elements in the ribbon bar you should iterate over all elements in groups in the RadRibbonBar structure.

The following forum thread might be quite useful on this topic: https://www.telerik.com/forums/iterate-trough-radribbonbar#faEsXbBwlE6tol9s7lvIig Feel free to modify and extend the example shown there.

I hope this information helps.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
RibbonBar
Asked by
James
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or