New to Telerik UI for WinFormsStart a free 30-day trial

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

Definition

Namespace:Telerik.WinControls

Assembly:Telerik.WinControls.dll

Syntax:

C#
public static class ControlHelper

Inheritance: objectControlHelper

Methods

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

C#
public static void BeginUpdate(Control control)
Parameters:controlControl

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

C#
public static void BringToFront(IntPtr handle, bool activate)
Parameters:handleIntPtr

The window handle to bring to front.

activatebool

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.

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

C#
public static void EndUpdate(Control control, bool invalidate)
Parameters:controlControlinvalidatebool

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

C#
public static IEnumerable<Control> EnumChildControls(Control parent, bool recursive, Predicate<Control> parentFilter)
Parameters:parentControlrecursiveboolparentFilterPredicate<Control>Returns:

IEnumerable<Control>

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

C#
public static IEnumerable<Control> EnumChildControls(Control parent, bool recursive)
Parameters:parentControlrecursiveboolReturns:

IEnumerable<Control>

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

C#
public static List<Control> FilterChildControls(Control parent, Filter filter, bool recursive)
Parameters:parentControlfilterFilterrecursiveboolReturns:

List<Control>

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

C#
public static T FindAncestor<T>(Control child) where T : Control
Parameters:childControlReturns:

T

C#
public static Control FindDescendant(Control parent, Type descendantType)
Parameters:parentControldescendantTypeTypeReturns:

Control

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

C#
public static T FindDescendant<T>(Control parent) where T : Control
Parameters:parentControlReturns:

T

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

C#
public static bool GetAnyDisposingInHierarchy(Control child)
Parameters:childControl

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.

Collects all child controls of given type.

C#
public static List<T> GetChildControls<T>(Control parent, bool recursive) where T : Control
Parameters:parentControlrecursiveboolReturns:

List<T>

C#
public static List<T> GetChildControls<T>(Control parent) where T : Control
Parameters:parentControlReturns:

List<T>

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

C#
public static bool GetControlStyle(Control instance, ControlStyles style)
Parameters:instanceControlstyleControlStylesReturns:

bool

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

C#
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.

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

C#
public static T GetFirstControl<T>(Control parent, bool recursive) where T : Control
Parameters:parentControlrecursiveboolReturns:

T

Gets the Control instance that currently contains the Keyboard focus.

C#
public static Control GetFocusedControl()
Returns:

Control

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

C#
public static T GetLastControl<T>(Control parent, bool recursive) where T : Control
Parameters:parentControlrecursiveboolReturns:

T

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

C#
public static T GetNextControl<T>(Control parent, T curr, bool recursive, bool forward, bool wrap) where T : Control
Parameters:parentControl

The parent control, which descendants are to be examined.

currT

The current T instance to start the search from.

recursivebool

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

forwardbool

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.

wrapbool

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

Returns:

T

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

C#
public static void InvalidateNonClient(Control frame, bool activate)
Parameters:frameControlactivatebool

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

C#
public static bool IsDescendant(Control parent, Control child)
Parameters:parentControlchildControlReturns:

bool

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

C#
public static void SendToBack(IntPtr handle, bool activate)
Parameters:handleIntPtr

The window handle to send to back.

activatebool

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.