tags:

views:

81

answers:

2

I need to check whether a control is a descendant of another control. Will Control.Contains do the job, or does that only search for first-level child controls?

+1  A: 

I just tested it, and it looks like it does indeed do a recursive search.

Blorgbeard
+6  A: 

Control.Contains makes a recursive search. So it will return true for this case:

ctrl1.Contains(ctrl3);

where ctrl1 contains ctrl2, and ctrl2 contains ctrl3 (for example).

BTW: .NET Reflector is a great tool to find out such things.

M4N