collections - Setting visiblilty of control using LINQ -
i'm working on refactoring code practice linq. reason can't code cooperate.
        //actioncontrols controlcollection var actioncontrols = flowlayoutpanel1.filtercontrols(c => c button);      //todo: optimize   foreach(var control in actioncontrols)   {       control.visible = workingitemdatatable.asenumerable().any(row => "btn" + row.field<string>("name") == control.name);   }   what trying now.
flowlayoutpanel1.filtercontrols(c => c button && c.name == "btntaskinfo"//btntaskinfo visible                    || workingitemdatatable.asenumerable().any(row => "btn" + row.field<string>("name") == c.name)).cast<button>()   but after casting button, can not figure out how set visible = false. advice?
you'd still need iterate controls, can this, assuming filtercontrols isn't more alias where:
var actioncontrols = flowlayoutpanel1.oftype<button>();   there "tricks" , shortcuts iterating , doing sets within lambda expression, makes code messy , hacks. can create own extension foreach (if there isn't 1 available if want anyway).
flowlayoutpanel1.oftype<button>().foreach(btn=>{btn.visible= ... });      
Comments
Post a Comment