ControlHelper
Provides utility methods for working with Windows Forms controls and window management operations.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public static class ControlHelper
Inheritance: objectControlHelper
Methods
Sends a WM_SETREDRAW message to the control, preventing any paint operation afterwards.
Brings a window to the front of the Z-order, optionally activating it.
public static void BringToFront(IntPtr handle, bool activate)
The window handle to bring to front.
activatebooltrue to activate the window (give it focus); false to only change its Z-order position.
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.
Enumerates all child controls of the specified parent and optionally traverses the entire tree using Depth-first approach.
Enumerates the Control tree, starting from the provided parent as a root, and collects all the child controls that match the specified filter.
Searches up the parent chain of controls, looking for an ancestor of the specified type.
public static T FindAncestor<T>(Control child) where T : Control
T
Searches down the control tree, using breadth-first approach, for a descendant of the specified type.
public static T FindDescendant<T>(Control parent) where T : Control
T
Determines whether any control in the hierarchy from the specified child control up to the root is disposing or disposed.
public static bool GetAnyDisposingInHierarchy(Control child)
The starting control to check, along with its parent hierarchy.
Returns:true if any control in the hierarchy is disposed or currently disposing; otherwise, false.
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.
public static List<T> GetChildControls<T>(Control parent) where T : Control
List<T>
Determines whether the specified ControlStyle is applied to the provided control.
public static bool GetControlStyle(Control instance, ControlStyles style)
Gets the Windows Forms control that is currently under the mouse cursor.
public static Control GetControlUnderMouse()
The Control instance under the mouse cursor, or null if no control is found.
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 Control instance that currently contains the Keyboard focus.
Gets the Control of type T that is descendant of the specified parent and is anchored to the specified current T instance.
public static T GetNextControl<T>(Control parent, T curr, bool recursive, bool forward, bool wrap) where T : Control
The parent control, which descendants are to be examined.
currTThe current T instance to start the search from.
recursiveboolTrue to perform depth-first traversal of the Control Tree, false to look-up direct children only.
forwardboolTrue 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.
wrapboolTrue to start the search from the beginning when end of the search is reached.
Returns:T
Sends a window to the back of the Z-order, optionally activating it.
public static void SendToBack(IntPtr handle, bool activate)
The window handle to send to back.
activatebooltrue to activate the window; false to only change its Z-order position.
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.