Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controls Collection and .Where?

Is there not a way to do the following??

For each ctrl as Control in Me.Controls.Where(function(x) x.Enabled = False)
    ctrl.Enabled = True
Next

Every which way I try, I get 'Where' is not a member of 'System.Web.UI.ControlCollection' presumably because ControlCollection is not enumerable?

like image 714
MetalPhoenix Avatar asked Jan 27 '26 12:01

MetalPhoenix


1 Answers

Most LINQ extension methods extend the type-safe IEnumerable(Of T).

ControlCollection predates generics and only implements IEnumerable, so the extension methods will not work.

You need to call .Cast(Of Control)() to return an IEnumerable(Of Control) which will accept extension methods.

like image 173
SLaks Avatar answered Jan 30 '26 04:01

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!