I use the following method to return a parent control of a specific type. This method is recursive and uses generics.
private Control GetParentControl(Control control)
{
if (control.Parent.GetType() == typeof(T1))
{
return control.Parent;
}
else
{
return GetParentControl(control.Parent);
}
}
