Skip to content

Instantly share code, notes, and snippets.

@ilivewithian
Created December 7, 2013 10:33
Show Gist options
  • Save ilivewithian/7839470 to your computer and use it in GitHub Desktop.
Save ilivewithian/7839470 to your computer and use it in GitHub Desktop.
public static T FindParent<T>(this Control target) where T : Control
{
if (target.Parent == null)
{
return null;
}
var parent = target.Parent as T;
if (parent != null)
{
return parent;
}
return target.Parent.FindParent<T>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment