ClassControlHelper
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
BeginUpdate(Control)
Sends a WM_SETREDRAW message to the control, preventing any paint operation afterwards.
Declaration
public static void BeginUpdate(Control control)
Parameters
control
BringToFront(IntPtr, bool)
Brings a window to the front of the Z-order, optionally activating it.
Declaration
public static void BringToFront(IntPtr handle, bool activate)
Parameters
handle
The window handle to bring to front.
activate
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.
EnumChildControls(Control, bool)
Enumerates all child controls of the specified parent and optionally traverses the entire tree using Depth-first approach.
EnumChildControls(Control, bool, Predicate<Control>)
Enumerates all child controls of the specified parent and optionally traverses the entire tree using Depth-first approach.
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.
FindAncestor<T>(Control)
Searches up the parent chain of controls, looking for an ancestor of the specified type.
Declaration
public static T FindAncestor<T>(Control child) where T : Control
Parameters
child
Returns
T
FindDescendant<T>(Control)
Searches down the control tree, using breadth-first approach, for a descendant of the specified type.
Declaration
public static T FindDescendant<T>(Control parent) where T : Control
Parameters
parent
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
public static bool GetAnyDisposingInHierarchy(Control child)
Parameters
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.
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
public static List<T> GetChildControls<T>(Control parent) where T : Control
Parameters
parent
Returns
List<T>
GetChildControls<T>(Control, bool)
Collects all child controls of given type.
GetControlStyle(Control, ControlStyles)
Determines whether the specified ControlStyle is applied to the provided control.
Declaration
public static bool GetControlStyle(Control instance, ControlStyles style)
Parameters
instance
style
Returns
GetControlUnderMouse()
Gets the Windows Forms control that is currently under the mouse cursor.
Declaration
public static Control GetControlUnderMouse()
Returns
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.
GetFocusedControl()
Gets the Control instance that currently contains the Keyboard focus.
GetLastControl<T>(Control, bool)
Gets the last Control of Type T, which is descendant of the specified Parent.
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
public static T GetNextControl<T>(Control parent, T curr, bool recursive, bool forward, bool wrap) where T : Control
Parameters
parent
The parent control, which descendants are to be examined.
curr
T
The current T instance to start the search from.
recursive
True to perform depth-first traversal of the Control Tree, false to look-up direct children only.
forward
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
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.
IsDescendant(Control, Control)
Determines whether the specified Child is contained within the specified Parent's Control Tree.
SendToBack(IntPtr, bool)
Sends a window to the back of the Z-order, optionally activating it.
Declaration
public static void SendToBack(IntPtr handle, bool activate)
Parameters
handle
The window handle to send to back.
activate
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.