Search code examples
c#winformslinqtelerikribbon

find control by name with linq


Hello folks is it possible to find a controll by its name via Linq?

I can iterate thorught contorl collection via for each

foreach (RibbonTab t in testRibbon.CommandTabs)
                    {
                        if (t.Name == tab.Name)
                        {
                            blnFound= true;

                        }
                    }

The idea is to save memory. I create telerik ribbon tabs dynamically and i want to see if the tab is there then don't create it also i want to check the ribbonbar if it has specific RadRibbonBarGroup and RadButtonElement by name same as for ribbontab so i dont make duplicates.

Sorry if i complicated a bit.


Solution

  • bool found = testRibbon.CommandTabs.Cast<RibbonTab>().Any(t => t.name == tab.Name);