by Pieter Brinkman
27. April 2010 04:43
I use the following method to return a parent control of a specific type. This method is recursive and uses generics.
[code:c#]
private Control GetParentControl<T1>(Control control)
{
if (control.Parent.GetType() == typeof(T1))
{
return control.Parent;
}
else
{
return GetParentControl<T1>(control.Parent);
}
}
[/code]