Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

IForm.Controls missing some controls

(7.5.3) I wanted to write a simple handler to iterate all controls on a form. I tried using form.Controls (a property of IForm inherited by all form interfaces). Only IForm and IControlsListControl expose a Controls property... IPanel does not. However, controls in panels are missing from the IForm.Controls collection. (Huh?) I got around the problem by using reflection on the form interface itself:


using System.Reflection;
foreach(PropertyInfo i in form.GetType().GetProperties()) {
    object o = i.GetValue(form,null);
    if(o is IControl) {
      // do something		

 Is there a way to do this without reflection?

Andy Freeman
TrellisPoint, LLC