Gorgon
Show / Hide Table of Contents

Class GorgonControlExtensions

Extension methods for the Control base class.

Inheritance
object
GorgonControlExtensions
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: System.Windows.Forms
Assembly: Gorgon.Windows.dll
Syntax
public static class GorgonControlExtensions

Methods

| Edit this page View Source

GetAncestor<T>(Control)

Function to retrieve the ancestor for this control that matches the type specifier.

Declaration
public static T GetAncestor<T>(this Control control) where T : Control
Parameters
Type Name Description
Control control

The control to start the search from.

Returns
Type Description
T

The very first ancestor of this control matching T, or null if the control has no ancestor of the given type.

Type Parameters
Name Description
T

The type of control to find. Must inherit from Control.

Exceptions
Type Condition
ArgumentNullException

Thrown when the control parameter is null.

| Edit this page View Source

GetFirstAncestor<T>(Control)

Function to retrieve the first ancestor of this control that matches the type specifier.

Declaration
public static T GetFirstAncestor<T>(this Control control) where T : Control
Parameters
Type Name Description
Control control

The control to start the search from.

Returns
Type Description
T

The very first ancestor of this control matching T, or null if the control has no ancestor of the given type.

Type Parameters
Name Description
T

The type of control to find. Must inherit from Control.

Exceptions
Type Condition
ArgumentNullException

Thrown when the control parameter is null.

| Edit this page View Source

GetForm<T>(Control)

Function to retrieve the form in which this control is contained.

Declaration
public static T GetForm<T>(this Control control) where T : Form
Parameters
Type Name Description
Control control

The control to start searching from.

Returns
Type Description
T

The Form of type T if found, null if not.

Type Parameters
Name Description
T

Type of form. Must inherit from Form.

Exceptions
Type Condition
ArgumentNullException

Thrown when the control parameter is null.

  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author