Class
ControlHelper

Provides utility methods for working with Windows Forms controls and window management operations.

Definition

Namespace:Telerik.WinControls

Assembly:Telerik.WinControls.dll

Syntax:

cs-api-definition
public static class ControlHelper

Inheritance: objectControlHelper

Methods

BeginUpdate(Control)

Sends a WM_SETREDRAW message to the control, preventing any paint operation afterwards.

Declaration

cs-api-definition
public static void BeginUpdate(Control control)

Parameters

control

Control

BringToFront(IntPtr, bool)

Brings a window to the front of the Z-order, optionally activating it.

Declaration

cs-api-definition
public static void BringToFront(IntPtr handle, bool activate)

Parameters

handle

IntPtr

The window handle to bring to front.

activate

bool

true to activate the window (give it focus); false to only change its Z-order position.

Remarks

This method positions the specified window at the top of the Z-order stack, making it visible above all other windows. When activate is true, the window also receives focus and becomes the active window.

This is commonly used for bringing popup windows, dialogs, or notification windows to the user's attention without necessarily stealing focus from the current application.

EndUpdate(Control, bool)

Resumes Control's painting, previously suspended by a BeginUpdate call.

Declaration

cs-api-definition
public static void EndUpdate(Control control, bool invalidate)

Parameters

control

Control

invalidate

bool

EnumChildControls(Control, bool)

Enumerates all child controls of the specified parent and optionally traverses the entire tree using Depth-first approach.

Declaration

cs-api-definition
public static IEnumerable<Control> EnumChildControls(Control parent, bool recursive)

Parameters

parent

Control

recursive

bool

Returns

IEnumerable<Control>

EnumChildControls(Control, bool, Predicate<Control>)

Enumerates all child controls of the specified parent and optionally traverses the entire tree using Depth-first approach.

Declaration

cs-api-definition
public static IEnumerable<Control> EnumChildControls(Control parent, bool recursive, Predicate<Control> parentFilter)

Parameters

parent

Control

recursive

bool

parentFilter

Predicate<Control>

Returns

IEnumerable<Control>

FilterChildControls(Control, Filter, bool)

Enumerates the Control tree, starting from the provided parent as a root, and collects all the child controls that match the specified filter.

Declaration

cs-api-definition
public static List<Control> FilterChildControls(Control parent, Filter filter, bool recursive)

Parameters

parent

Control

filter

Filter

recursive

bool

Returns

List<Control>

FindAncestor<T>(Control)

Searches up the parent chain of controls, looking for an ancestor of the specified type.

Declaration

cs-api-definition
public static T FindAncestor<T>(Control child) where T : Control

Parameters

child

Control

Returns

T

FindDescendant(Control, Type)

Declaration

cs-api-definition
public static Control FindDescendant(Control parent, Type descendantType)

Parameters

parent

Control

descendantType

Type

Returns

Control

FindDescendant<T>(Control)

Searches down the control tree, using breadth-first approach, for a descendant of the specified type.

Declaration

cs-api-definition
public static T FindDescendant<T>(Control parent) where T : Control

Parameters

parent

Control

Returns

T

GetAnyDisposingInHierarchy(Control)

Determines whether any control in the hierarchy from the specified child control up to the root is disposing or disposed.

Declaration

cs-api-definition
public static bool GetAnyDisposingInHierarchy(Control child)

Parameters

child

Control

The starting control to check, along with its parent hierarchy.

Returns

bool

true if any control in the hierarchy is disposed or currently disposing; otherwise, false.

Remarks

This method walks up the control hierarchy from the specified child control to the root, checking each control's IsDisposed and Disposing properties. It's useful for determining whether it's safe to perform operations on a control.

This check is important in scenarios where controls might be disposed asynchronously or where you need to ensure that parent controls are still valid before performing operations.

GetChildControls<T>(Control)

Declaration

cs-api-definition
public static List<T> GetChildControls<T>(Control parent) where T : Control

Parameters

parent

Control

Returns

List<T>

GetChildControls<T>(Control, bool)

Collects all child controls of given type.

Declaration

cs-api-definition
public static List<T> GetChildControls<T>(Control parent, bool recursive) where T : Control

Parameters

parent

Control

recursive

bool

Returns

List<T>

GetControlStyle(Control, ControlStyles)

Determines whether the specified ControlStyle is applied to the provided control.

Declaration

cs-api-definition
public static bool GetControlStyle(Control instance, ControlStyles style)

Parameters

instance

Control

style

ControlStyles

Returns

bool

GetControlUnderMouse()

Gets the Windows Forms control that is currently under the mouse cursor.

Declaration

cs-api-definition
public static Control GetControlUnderMouse()

Returns

Control

The Control instance under the mouse cursor, or null if no control is found.

Remarks

This method uses the current mouse position and Windows API calls to determine which control the mouse is currently over. It first gets the window handle at the mouse position using WindowFromPoint, then converts that handle to a managed Control reference.

This is useful for drag-and-drop operations, hit testing, and determining context for mouse-related operations when you need to identify the target control dynamically.

GetFirstControl<T>(Control, bool)

Gets the first Control of Type T, which is descendant of the specified Parent.

Declaration

cs-api-definition
public static T GetFirstControl<T>(Control parent, bool recursive) where T : Control

Parameters

parent

Control

recursive

bool

Returns

T

GetFocusedControl()

Gets the Control instance that currently contains the Keyboard focus.

Declaration

cs-api-definition
public static Control GetFocusedControl()

Returns

Control

GetLastControl<T>(Control, bool)

Gets the last Control of Type T, which is descendant of the specified Parent.

Declaration

cs-api-definition
public static T GetLastControl<T>(Control parent, bool recursive) where T : Control

Parameters

parent

Control

recursive

bool

Returns

T

GetNextControl<T>(Control, T, bool, bool, bool)

Gets the Control of type T that is descendant of the specified parent and is anchored to the specified current T instance.

Declaration

cs-api-definition
public static T GetNextControl<T>(Control parent, T curr, bool recursive, bool forward, bool wrap) where T : Control

Parameters

parent

Control

The parent control, which descendants are to be examined.

curr

T

The current T instance to start the search from.

recursive

bool

True to perform depth-first traversal of the Control Tree, false to look-up direct children only.

forward

bool

True to search for a T instance that is next to the current specified one, false to search for a T instance that is previous to the current specified one.

wrap

bool

True to start the search from the beginning when end of the search is reached.

Returns

T

InvalidateNonClient(Control, bool)

Forces the non-client area of the specified Control instance to be re-evaluated.

Declaration

cs-api-definition
public static void InvalidateNonClient(Control frame, bool activate)

Parameters

frame

Control

activate

bool

IsDescendant(Control, Control)

Determines whether the specified Child is contained within the specified Parent's Control Tree.

Declaration

cs-api-definition
public static bool IsDescendant(Control parent, Control child)

Parameters

parent

Control

child

Control

Returns

bool

SendToBack(IntPtr, bool)

Sends a window to the back of the Z-order, optionally activating it.

Declaration

cs-api-definition
public static void SendToBack(IntPtr handle, bool activate)

Parameters

handle

IntPtr

The window handle to send to back.

activate

bool

true to activate the window; false to only change its Z-order position.

Remarks

This method positions the specified window at the bottom of the Z-order stack, making it appear behind all other windows. This is typically used to minimize the visual impact of background windows or utility windows.

Note that activating a window that's sent to back may cause visual inconsistencies, so activate is usually set to false for this operation.