Skip to main content
Version: 4.1

ControlExtensions

Namespace: Wisej.Web.Markup

Assembly: Wisej.Framework (4.1.0.0)

Adds fluent markup extension methods to the Control class.

public class ControlExtensions

Methods

Static member AccessibleDescription<TControl>(control, accessibleDescription)

Sets the accessible description for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the accessible description.
accessibleDescriptionStringThe description to be set for accessibility purposes.

Returns: TControl. The control with the updated accessible description.

Static member AccessibleName<TControl>(control, accessibleName)

Sets the accessible name for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the accessible name.
accessibleNameStringThe name to be set for accessibility purposes.

Returns: TControl. The control with the updated accessible name.

Static member AllowDrop<TControl>(control, allowDrop)

Sets the AllowDrop property for the specified control, enabling or disabling drag-and-drop operations.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the AllowDrop property.
allowDropBooleanA boolean value indicating whether to allow drag-and-drop operations. Default is false.

Returns: TControl. The control with the updated AllowDrop property.

Static member Also<TControl>(control, action)

Executes a specified action on the control and returns the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which the action is to be performed.
actionAction<TControl>The action to be executed on the control.

Returns: TControl. The control after the action has been executed.

This method allows for chaining operations on a control by executing an action and returning the control itself.


myControl.Also(c => c.Text = "Updated Text").BackColor(Color.Red);

Static member Anchor<TControl>(control, anchors)

Sets the anchor styles for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the anchor styles.
anchorsAnchorStylesThe anchor styles to be applied to the control.

Returns: TControl. The control with the updated anchor styles.

Static member Anonymous<TControl>(control, value)

ParameterTypeDescription
TControl
controlTControl
valueBoolean

Returns: TControl.

Static member AutoScrollOffset<TControl>(control, offset)

Sets the auto-scroll offset for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the auto-scroll offset.
offsetPointThe point representing the auto-scroll offset.

Returns: TControl. The control with the updated auto-scroll offset.

Static member AutoSize<TControl>(control, autoSize)

Sets the AutoSize property for the specified control, enabling or disabling automatic resizing.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the AutoSize property.
autoSizeBooleanA boolean value indicating whether to enable automatic resizing. Default is false.

Returns: TControl. The control with the updated AutoSize property.

Static member BackColor<TControl>(control, color)

Sets the background color for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the background color.
colorColorThe color to be set as the background color.

Returns: TControl. The control with the updated background color.

Static member BackgroundImage<TControl>(control, image)

Sets the background image for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the background image.
imageImageThe image to be set as the background image.

Returns: TControl. The control with the updated background image.

Static member BackgroundImageLayout<TControl>(control, layout)

Sets the layout of the background image for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the background image layout.
layoutImageLayoutThe layout to be applied to the background image.

Returns: TControl. The control with the updated background image layout.

Static member Bounds<TControl>(control, bounds)

Sets the bounds of the specified control using a Rectangle.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the bounds.
boundsRectangleThe rectangle representing the new bounds of the control.

Returns: TControl. The control with the updated bounds.

Static member Bounds<TControl>(control, top, left)

Sets the top and left position of the specified control, maintaining its current width and height.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the top and left position.
topInt32The new top position of the control.
leftInt32The new left position of the control.

Returns: TControl. The control with the updated top and left position.

Static member Bounds<TControl>(control, top, left, width, height)

Sets the bounds of the specified control using specified top, left, width, and height values.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the bounds.
topInt32The new top position of the control.
leftInt32The new left position of the control.
widthInt32The new width of the control.
heightInt32The new height of the control.

Returns: TControl. The control with the updated bounds.

Static member BringToFront<TControl>(control)

Brings the control to the front of the z-order.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to bring to the front.

Returns: TControl. The control instance after being brought to the front.

This method changes the z-order of the control so that it appears in front of all other controls.

Static member Call<TControl>(control, function, args)

Invokes a specified JavaScript function on the control with the provided arguments.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance on which to invoke the function.
functionStringThe name of the function to call.
argsObject[]An array of arguments to pass to the function.

Returns: TControl. The control instance after the function call.

This extension method allows you to call a function on a control dynamically by name, passing any required arguments.

Static member Call<TControl>(control, function, callback, args)

Invokes a specified JavaScript function on the control with the provided arguments and a callback.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance on which to invoke the function.
functionStringThe name of the function to call.
callbackAction<Object>A callback to be executed with the result of the function call.
argsObject[]An array of arguments to pass to the function.

Returns: TControl. The control instance after the function call.

This extension method allows you to call a function on a control dynamically by name, passing any required arguments and a callback to handle the result.

Static member Capture<TControl>(control, capture)

Sets the capture property for the specified control, determining whether the control has captured the mouse.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the capture property.
captureBooleanA boolean value indicating whether the control should capture the mouse. Default is false.

Returns: TControl. The control with the updated capture property.

Static member CausesValidation<TControl>(control, causesValidation)

Sets the CausesValidation property for the specified control, determining whether the control causes validation to be performed on any controls that require validation.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the CausesValidation property.
causesValidationBooleanA boolean value indicating whether the control causes validation. Default is true.

Returns: TControl. The control with the updated CausesValidation property.

Static member CenterToParent<TControl>(control, horizontal, vertical)

Centers the control within its parent, optionally horizontally and/or vertically.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to center.
horizontalBooleanIf true, centers the control horizontally.
verticalBooleanIf true, centers the control vertically.

Returns: TControl. The control instance after centering.

This method centers the control within its parent container based on the specified axes.

Static member ClientSize<TControl>(control, clientSize)

Sets the client size for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the client size.
clientSizeSizeThe size to be set as the client size of the control.

Returns: TControl. The control with the updated client size.

Static member ContextMenu<TControl>(control, contextMenu)

Sets the context menu for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the context menu.
contextMenuContextMenuThe context menu to be associated with the control.

Returns: TControl. The control with the updated context menu.

Static member Controls<TControl>(control, children)

Adds an array of child controls to the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the child controls will be added.
childrenControl[]An array of child controls to be added.

Returns: TControl. The control with the added child controls.

This method suspends the layout of the control, adds the child controls, and then resumes the layout. Controls with Fill are brought to the front.


myControl.Controls(new Button(), new TextBox());

Static member CreateControl<TControl>(control)

Forces the creation of the control and its handle.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to create.

Returns: TControl. The control instance after creation.

This method ensures that the control and its underlying handle are created.

Static member Cursor<TControl>(control, cursor)

Sets the cursor for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the cursor.
cursorCursorThe cursor to be used by the control.

Returns: TControl. The control with the updated cursor.

Static member Dock<TControl>(control, dockPosition)

Sets the dock style for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the dock style.
dockPositionDockStyleThe dock style to be applied to the control.

Returns: TControl. The control with the updated dock style.

Static member Enabled<TControl>(control, enabled)

Sets the enabled state for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the enabled state.
enabledBooleanA boolean value indicating whether the control should be enabled. Default is true.

Returns: TControl. The control with the updated enabled state.

Static member Eval<TControl>(control, javaScript, callback)

Evaluates the specified JavaScript code in the context of the control, optionally with a callback.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance on which to evaluate the JavaScript.
javaScriptStringThe JavaScript code to evaluate.
callback optionalAction<Object>An optional callback to handle the result of the evaluation. Default is null.

Returns: TControl. The control instance after the JavaScript evaluation.

This method executes JavaScript code in the context of the control. If a callback is provided, it will be invoked with the result of the evaluation.

Static member Focusable<TControl>(control, value)

ParameterTypeDescription
TControl
controlTControl
valueBoolean

Returns: TControl.

Static member Font<TControl>(control, font)

Sets the font for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the font.
fontFontThe font to be applied to the control.

Returns: TControl. The control with the updated font.

Static member FontSize<TControl>(control, size)

Sets the font size for the specified control while maintaining the current font family.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the font size.
sizeInt32The new font size to be applied to the control.

Returns: TControl. The control with the updated font size.

Static member ForeColor<TControl>(control, foreColor)

Sets the foreground color for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the foreground color.
foreColorColorThe color to be set as the foreground color.

Returns: TControl. The control with the updated foreground color.

Static member Height<TControl>(control, height)

Sets the height for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the height.
heightInt32The new height to be applied to the control.

Returns: TControl. The control with the updated height.

Static member Hide<TControl>(control)

Hides the control.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to hide.

Returns: TControl. The control instance after being hidden.

This method makes the control invisible.

Static member Leave<TControl>(control, action)

Attaches an action to be executed when the control loses focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control loses focus.

Returns: TControl. The control with the attached leave event action.

This method allows you to specify an action that will be executed when the control's Leave event is triggered.


myControl.Leave(c => AlertBox.Show($"{c.Name} lost focus"));

Static member Left<TControl>(control, left)

Sets the left position for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the left position.
leftInt32The new left position to be applied to the control.

Returns: TControl. The control with the updated left position.

Static member Location<TControl>(control, location)

Sets the location for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the location.
locationPointThe point representing the new location of the control.

Returns: TControl. The control with the updated location.

Static member Location<TControl>(control, left, top)

Sets the location for the specified control using left and top coordinates.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the location.
leftInt32The new left position of the control.
topInt32The new top position of the control.

Returns: TControl. The control with the updated location.

Static member Margin<TControl>(control, margin)

Sets the margin for the specified control using a Padding object.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the margin.
marginPaddingThe padding to be set as the margin of the control.

Returns: TControl. The control with the updated margin.

Static member Margin<TControl>(control, padding)

Sets the margin for the specified control using an array of integers.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the margin.
paddingInt32[]An array of integers representing the margin. Must be 1 (all), 2 (horizontal, vertical), or 4 (left, top, right, bottom).

Returns: TControl. The control with the updated margin.

This method allows setting the margin using different configurations of padding values.


myControl.Margin(5); // All sides
myControl.Margin(5, 10); // Horizontal and vertical
myControl.Margin(5, 10, 15, 20); // Left, top, right, bottom

Throws:

Static member MaximumSize<TControl>(control, size)

Sets the maximum size for the specified control using a Size object.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the maximum size.
sizeSizeThe size to be set as the maximum size of the control.

Returns: TControl. The control with the updated maximum size.

Static member MaximumSize<TControl>(control, width, height)

Sets the maximum size for the specified control using width and height values.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the maximum size.
widthInt32The maximum width of the control.
heightInt32The maximum height of the control.

Returns: TControl. The control with the updated maximum size.

Static member MinimumSize<TControl>(control, size)

Sets the minimum size for the specified control using a Size object.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the minimum size.
sizeSizeThe size to be set as the minimum size of the control.

Returns: TControl. The control with the updated minimum size.

Static member MinimumSize<TControl>(control, width, height)

Sets the minimum size for the specified control using width and height values.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the minimum size.
widthInt32The minimum width of the control.
heightInt32The minimum height of the control.

Returns: TControl. The control with the updated minimum size.

Static member Name<TControl>(control, name)

Sets the name for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the name.
nameStringThe name to be assigned to the control.

Returns: TControl. The control with the updated name.

Static member OnAutoSizeChanged<TControl>(control, action)

Attaches an action to be executed when the AutoSize property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the AutoSize property changes.

Returns: TControl. The control with the attached AutoSizeChanged event action.

This method allows you to specify an action that will be executed when the control's AutoSizeChanged event is triggered.


myControl.OnAutoSizeChanged(c => AlertBox.Show($"{c.Name} AutoSize changed"));

Static member OnBackColorChanged<TControl>(control, action)

Attaches an action to be executed when the BackColor property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the BackColor property changes.

Returns: TControl. The control with the attached BackColorChanged event action.

This method allows you to specify an action that will be executed when the control's BackColorChanged event is triggered.


myControl.OnBackColorChanged(c => AlertBox.Show($"{c.Name} BackColor changed"));

Static member OnBackgroundImageChanged<TControl>(control, action)

Attaches an action to be executed when the BackgroundImage property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the BackgroundImage property changes.

Returns: TControl. The control with the attached BackgroundImageChanged event action.

This method allows you to specify an action that will be executed when the control's BackgroundImageChanged event is triggered.


myControl.OnBackgroundImageChanged(c => AlertBox.Show($"{c.Name} BackgroundImage changed"));

Static member OnBackgroundImageLayoutChanged<TControl>(control, action)

Attaches an action to be executed when the BackgroundImageLayout property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the BackgroundImageLayout property changes.

Returns: TControl. The control with the attached BackgroundImageLayoutChanged event action.

This method allows you to specify an action that will be executed when the control's BackgroundImageLayoutChanged event is triggered.


myControl.OnBackgroundImageLayoutChanged(c => AlertBox.Show($"{c.Name} BackgroundImageLayout changed"));

Static member OnBindingContextChanged<TControl>(control, action)

Attaches an action to be executed when the BindingContext property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the BindingContext property changes.

Returns: TControl. The control with the attached BindingContextChanged event action.

This method allows you to specify an action that will be executed when the control's BindingContextChanged event is triggered.


myControl.OnBindingContextChanged(c => AlertBox.Show($"{c.Name} BindingContext changed"));

Static member OnCausesValidationChanged<TControl>(control, action)

Attaches an action to be executed when the CausesValidation property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the CausesValidation property changes.

Returns: TControl. The control with the attached CausesValidationChanged event action.

This method allows you to specify an action that will be executed when the control's CausesValidationChanged event is triggered.


myControl.OnCausesValidationChanged(c => AlertBox.Show($"{c.Name} CausesValidation changed"));

Static member OnClick<TControl>(control, action)

Attaches an action to be executed when the control is clicked.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control is clicked.

Returns: TControl. The control with the attached Click event action.

This method allows you to specify an action that will be executed when the control's Click event is triggered.


myControl.OnClick(c => AlertBox.Show($"{c.Name} was clicked"));

Static member OnClientSizeChanged<TControl>(control, action)

Attaches an action to be executed when the ClientSize property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the ClientSize property changes.

Returns: TControl. The control with the attached ClientSizeChanged event action.

This method allows you to specify an action that will be executed when the control's ClientSizeChanged event is triggered.


myControl.OnClientSizeChanged(c => AlertBox.Show($"{c.Name} ClientSize changed"));

Static member OnContextMenuChanged<TControl>(control, action)

Attaches an action to be executed when the ContextMenu property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the ContextMenu property changes.

Returns: TControl. The control with the attached ContextMenuChanged event action.

This method allows you to specify an action that will be executed when the control's ContextMenuChanged event is triggered.


myControl.OnContextMenuChanged(c => AlertBox.Show($"{c.Name} ContextMenu changed"));

Static member OnControlAdded<TControl>(control, action)

Attaches an action to be executed when a control is added to the control's collection.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, ControlEventArgs>The action to be executed when a control is added, with the event arguments provided.

Returns: TControl. The control with the attached ControlAdded event action.

This method allows you to specify an action that will be executed when the control's ControlAdded event is triggered.


myControl.OnControlAdded((c, args) => AlertBox.Show($"{args.Control.Name} was added to {c.Name}"));

Static member OnControlRemoved<TControl>(control, action)

Attaches an action to be executed when a control is removed from the control's collection.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, ControlEventArgs>The action to be executed when a control is removed, with the event arguments provided.

Returns: TControl. The control with the attached ControlRemoved event action.

This method allows you to specify an action that will be executed when the control's ControlRemoved event is triggered.


myControl.OnControlRemoved((c, args) => AlertBox.Show($"{args.Control.Name} was removed from {c.Name}"));

Static member OnCursorChanged<TControl>(control, action)

Attaches an action to be executed when the Cursor property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Cursor property changes.

Returns: TControl. The control with the attached CursorChanged event action.

This method allows you to specify an action that will be executed when the control's CursorChanged event is triggered.


myControl.OnCursorChanged(c => AlertBox.Show($"{c.Name} Cursor changed"));

Static member OnDockChanged<TControl>(control, action)

Attaches an action to be executed when the Dock property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Dock property changes.

Returns: TControl. The control with the attached DockChanged event action.

This method allows you to specify an action that will be executed when the control's DockChanged event is triggered.


myControl.OnDockChanged(c => AlertBox.Show($"{c.Name} Dock changed"));

Static member OnDoubleClick<TControl>(control, action)

Attaches an action to be executed when the control is double-clicked.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control is double-clicked.

Returns: TControl. The control with the attached DoubleClick event action.

This method allows you to specify an action that will be executed when the control's DoubleClick event is triggered.


myControl.OnDoubleClick(c => AlertBox.Show($"{c.Name} was double-clicked"));

Static member OnDragDrop<TControl>(control, action)

Attaches an action to be executed when a drag-and-drop operation is completed on the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, DragEventArgs>The action to be executed when a drag-and-drop operation is completed, with the event arguments provided.

Returns: TControl. The control with the attached DragDrop event action.

This method allows you to specify an action that will be executed when the control's DragDrop event is triggered.


myControl.OnDragDrop((c, args) => AlertBox.Show($"{c.Name} received a drag drop"));

Static member OnDragEnter<TControl>(control, action)

Attaches an action to be executed when an object is dragged into the control's bounds.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, DragEventArgs>The action to be executed when an object is dragged into the control, with the event arguments provided.

Returns: TControl. The control with the attached DragEnter event action.

This method allows you to specify an action that will be executed when the control's DragEnter event is triggered.


myControl.OnDragEnter((c, args) => AlertBox.Show($"{c.Name} drag enter"));

Static member OnDragLeave<TControl>(control, action)

Attaches an action to be executed when an object is dragged out of the control's bounds.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when an object is dragged out of the control.

Returns: TControl. The control with the attached DragLeave event action.

This method allows you to specify an action that will be executed when the control's DragLeave event is triggered.


myControl.OnDragLeave(c => AlertBox.Show($"{c.Name} drag leave"));

Static member OnDragOver<TControl>(control, action)

Attaches an action to be executed when an object is dragged over the control's bounds.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, DragEventArgs>The action to be executed when an object is dragged over the control, with the event arguments provided.

Returns: TControl. The control with the attached DragOver event action.

This method allows you to specify an action that will be executed when the control's DragOver event is triggered.


myControl.OnDragOver((c, args) => AlertBox.Show($"{c.Name} drag over"));

Static member OnEnabledChanged<TControl>(control, action)

Attaches an action to be executed when the Enabled property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Enabled property changes.

Returns: TControl. The control with the attached EnabledChanged event action.

This method allows you to specify an action that will be executed when the control's EnabledChanged event is triggered.


myControl.OnEnabledChanged(c => AlertBox.Show($"{c.Name} Enabled changed"));

Static member OnEnter<TControl>(control, action)

Attaches an action to be executed when the control receives focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control receives focus.

Returns: TControl. The control with the attached Enter event action.

This method allows you to specify an action that will be executed when the control's Enter event is triggered.


myControl.OnEnter(c => AlertBox.Show($"{c.Name} received focus"));

Static member OnFontChanged<TControl>(control, action)

Attaches an action to be executed when the Font property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Font property changes.

Returns: TControl. The control with the attached FontChanged event action.

This method allows you to specify an action that will be executed when the control's FontChanged event is triggered.


myControl.OnFontChanged(c => AlertBox.Show($"{c.Name} Font changed"));

Static member OnForeColorChanged<TControl>(control, action)

Attaches an action to be executed when the ForeColor property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the ForeColor property changes.

Returns: TControl. The control with the attached ForeColorChanged event action.

This method allows you to specify an action that will be executed when the control's ForeColorChanged event is triggered.


myControl.OnForeColorChanged(c => AlertBox.Show($"{c.Name} ForeColor changed"));

Static member OnGotFocus<TControl>(control, action)

Attaches an action to be executed when the control receives focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control receives focus.

Returns: TControl. The control with the attached GotFocus event action.

This method allows you to specify an action that will be executed when the control's GotFocus event is triggered.


myControl.OnGotFocus(c => AlertBox.Show($"{c.Name} got focus"));

Static member OnHandleCreated<TControl>(control, action)

Attaches an action to be executed when the control's handle is created.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control's handle is created.

Returns: TControl. The control with the attached HandleCreated event action.

This method allows you to specify an action that will be executed when the control's HandleCreated event is triggered.


myControl.OnHandleCreated(c => AlertBox.Show($"{c.Name} handle created"));

Static member OnHandleDestroyed<TControl>(control, action)

Attaches an action to be executed when the control's handle is destroyed.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control's handle is destroyed.

Returns: TControl. The control with the attached HandleDestroyed event action.

This method allows you to specify an action that will be executed when the control's HandleDestroyed event is triggered.


myControl.OnHandleDestroyed(c => AlertBox.Show($"{c.Name} handle destroyed"));

Static member OnHelpRequested<TControl>(control, action)

Attaches an action to be executed when a help request is made for the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, HelpEventArgs>The action to be executed when a help request is made, with the event arguments provided.

Returns: TControl. The control with the attached HelpRequested event action.

This method allows you to specify an action that will be executed when the control's HelpRequested event is triggered.


myControl.OnHelpRequested((c, args) => AlertBox.Show($"{c.Name} help requested"));

Static member OnKeyDown<TControl>(control, action)

Attaches an action to be executed when a key is pressed while the control has focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, KeyEventArgs>The action to be executed when a key is pressed, with the event arguments provided.

Returns: TControl. The control with the attached KeyDown event action.

This method allows you to specify an action that will be executed when the control's KeyDown event is triggered.


myControl.OnKeyDown((c, args) => AlertBox.Show($"{c.Name} key down: {args.KeyCode}"));

Static member OnKeyPress<TControl>(control, action)

Attaches an action to be executed when a key is pressed and released while the control has focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, KeyPressEventArgs>The action to be executed when a key is pressed and released, with the event arguments provided.

Returns: TControl. The control with the attached KeyPress event action.

This method allows you to specify an action that will be executed when the control's KeyPress event is triggered.


myControl.OnKeyPress((c, args) => AlertBox.Show($"{c.Name} key press: {args.KeyChar}"));

Static member OnKeyUp<TControl>(control, action)

Attaches an action to be executed when a key is released while the control has focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, KeyEventArgs>The action to be executed when a key is released, with the event arguments provided.

Returns: TControl. The control with the attached KeyUp event action.

This method allows you to specify an action that will be executed when the control's KeyUp event is triggered.


myControl.OnKeyUp((c, args) => AlertBox.Show($"{c.Name} key up: {args.KeyCode}"));

Static member OnLayout<TControl>(control, action)

Attaches an action to be executed when the layout of the control is changed.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, LayoutEventArgs>The action to be executed when the layout changes, with the event arguments provided.

Returns: TControl. The control with the attached Layout event action.

This method allows you to specify an action that will be executed when the control's Layout event is triggered.


myControl.OnLayout((c, args) => AlertBox.Show($"{c.Name} layout changed"));

Static member OnLocationChanged<TControl>(control, action)

Attaches an action to be executed when the Location property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Location property changes.

Returns: TControl. The control with the attached LocationChanged event action.

This method allows you to specify an action that will be executed when the control's LocationChanged event is triggered.


myControl.OnLocationChanged(c => AlertBox.Show($"{c.Name} location changed"));

Static member OnLostFocus<TControl>(control, action)

Attaches an action to be executed when the control loses focus.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control loses focus.

Returns: TControl. The control with the attached LostFocus event action.

This method allows you to specify an action that will be executed when the control's LostFocus event is triggered.


myControl.OnLostFocus(c => AlertBox.Show($"{c.Name} lost focus"));

Static member OnMarginChanged<TControl>(control, action)

Attaches an action to be executed when the Margin property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Margin property changes.

Returns: TControl. The control with the attached MarginChanged event action.

This method allows you to specify an action that will be executed when the control's MarginChanged event is triggered.


myControl.OnMarginChanged(c => AlertBox.Show($"{c.Name} margin changed"));

Static member OnMouseCaptureChanged<TControl>(control, action)

Attaches an action to be executed when the mouse capture changes for the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the mouse capture changes.

Returns: TControl. The control with the attached MouseCaptureChanged event action.

This method allows you to specify an action that will be executed when the control's MouseCaptureChanged event is triggered.


myControl.OnMouseCaptureChanged(c => AlertBox.Show($"{c.Name} mouse capture changed"));

Static member OnMouseClick<TControl>(control, action)

Attaches an action to be executed when the control is clicked with the mouse.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when the control is clicked, with the event arguments provided.

Returns: TControl. The control with the attached MouseClick event action.

This method allows you to specify an action that will be executed when the control's MouseClick event is triggered.


myControl.OnMouseClick((c, args) => AlertBox.Show($"{c.Name} mouse click at {args.Location}"));

Static member OnMouseDoubleClick<TControl>(control, action)

Attaches an action to be executed when the control is double-clicked with the mouse.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when the control is double-clicked, with the event arguments provided.

Returns: TControl. The control with the attached MouseDoubleClick event action.

This method allows you to specify an action that will be executed when the control's MouseDoubleClick event is triggered.


myControl.OnMouseDoubleClick((c, args) => AlertBox.Show($"{c.Name} mouse double-click at {args.Location}"));

Static member OnMouseDown<TControl>(control, action)

Attaches an action to be executed when a mouse button is pressed while the pointer is over the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when a mouse button is pressed, with the event arguments provided.

Returns: TControl. The control with the attached MouseDown event action.

This method allows you to specify an action that will be executed when the control's MouseDown event is triggered.


myControl.OnMouseDown((c, args) => AlertBox.Show($"{c.Name} mouse down at {args.Location}"));

Static member OnMouseEnter<TControl>(control, action)

Attaches an action to be executed when the mouse pointer enters the control's bounds.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the mouse pointer enters the control.

Returns: TControl. The control with the attached MouseEnter event action.

This method allows you to specify an action that will be executed when the control's MouseEnter event is triggered.


myControl.OnMouseEnter(c => AlertBox.Show($"{c.Name} mouse entered"));

Static member OnMouseHover<TControl>(control, action)

Attaches an action to be executed when the mouse pointer hovers over the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the mouse pointer hovers over the control.

Returns: TControl. The control with the attached MouseHover event action.

This method allows you to specify an action that will be executed when the control's MouseHover event is triggered.


myControl.OnMouseHover(c => AlertBox.Show($"{c.Name} mouse hover"));

Static member OnMouseLeave<TControl>(control, action)

Attaches an action to be executed when the mouse pointer leaves the control's bounds.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the mouse pointer leaves the control.

Returns: TControl. The control with the attached MouseLeave event action.

This method allows you to specify an action that will be executed when the control's MouseLeave event is triggered.


myControl.OnMouseLeave(c => AlertBox.Show($"{c.Name} mouse left"));

Static member OnMouseMove<TControl>(control, action)

Attaches an action to be executed when the mouse pointer moves over the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when the mouse pointer moves, with the event arguments provided.

Returns: TControl. The control with the attached MouseMove event action.

This method allows you to specify an action that will be executed when the control's MouseMove event is triggered.


myControl.OnMouseMove((c, args) => AlertBox.Show($"{c.Name} mouse move at {args.Location}"));

Static member OnMouseUp<TControl>(control, action)

Attaches an action to be executed when a mouse button is released while the pointer is over the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when a mouse button is released, with the event arguments provided.

Returns: TControl. The control with the attached MouseUp event action.

This method allows you to specify an action that will be executed when the control's MouseUp event is triggered.


myControl.OnMouseUp((c, args) => AlertBox.Show($"{c.Name} mouse up at {args.Location}"));

Static member OnMouseWheel<TControl>(control, action)

Attaches an action to be executed when the mouse wheel is rotated while the pointer is over the control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, MouseEventArgs>The action to be executed when the mouse wheel is rotated, with the event arguments provided.

Returns: TControl. The control with the attached MouseWheel event action.

This method allows you to specify an action that will be executed when the control's MouseWheel event is triggered.


myControl.OnMouseWheel((c, args) => AlertBox.Show($"{c.Name} mouse wheel moved"));

Static member OnMove<TControl>(control, action)

Attaches an action to be executed when the control is moved.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control is moved.

Returns: TControl. The control with the attached Move event action.

This method allows you to specify an action that will be executed when the control's Move event is triggered.


myControl.OnMove(c => AlertBox.Show($"{c.Name} moved"));

Static member OnPaddingChanged<TControl>(control, action)

Attaches an action to be executed when the Padding property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Padding property changes.

Returns: TControl. The control with the attached PaddingChanged event action.

This method allows you to specify an action that will be executed when the control's PaddingChanged event is triggered.


myControl.OnPaddingChanged(c => AlertBox.Show($"{c.Name} padding changed"));

Static member OnPaint<TControl>(control, action)

Attaches an action to be executed when the control is repainted.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, PaintEventArgs>The action to be executed when the control is repainted, with the event arguments provided.

Returns: TControl. The control with the attached Paint event action.

This method allows you to specify an action that will be executed when the control's Paint event is triggered.


myControl.OnPaint((c, args) => AlertBox.Show($"{c.Name} is being painted"));

Static member OnParentChanged<TControl>(control, action)

Attaches an action to be executed when the Parent property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Parent property changes.

Returns: TControl. The control with the attached ParentChanged event action.

This method allows you to specify an action that will be executed when the control's ParentChanged event is triggered.


myControl.OnParentChanged(c => AlertBox.Show($"{c.Name} parent changed"));

Static member OnPreviewKeyDown<TControl>(control, action)

Attaches an action to be executed when a key is pressed while the control has focus, before the key event is processed.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, PreviewKeyDownEventArgs>The action to be executed when a key is pressed, with the event arguments provided.

Returns: TControl. The control with the attached PreviewKeyDown event action.

This method allows you to specify an action that will be executed when the control's PreviewKeyDown event is triggered.


myControl.OnPreviewKeyDown((c, args) => AlertBox.Show($"{c.Name} preview key down: {args.KeyCode}"));

Static member OnQueryContinueDrag<TControl>(control, action)

Attaches an action to be executed during a drag-and-drop operation to determine whether the drag should continue.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, QueryContinueDragEventArgs>The action to be executed during the drag operation, with the event arguments provided.

Returns: TControl. The control with the attached QueryContinueDrag event action.

This method allows you to specify an action that will be executed when the control's QueryContinueDrag event is triggered.


myControl.OnQueryContinueDrag((c, args) => AlertBox.Show($"{c.Name} query continue drag"));

Static member OnResize<TControl>(control, action)

Attaches an action to be executed when the control is resized.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control is resized.

Returns: TControl. The control with the attached Resize event action.

This method allows you to specify an action that will be executed when the control's Resize event is triggered.


myControl.OnResize(c => AlertBox.Show($"{c.Name} resized"));

Static member ONRightToLeftChanged<TControl>(control, action)

Attaches an action to be executed when the RightToLeft property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the RightToLeft property changes.

Returns: TControl. The control with the attached RightToLeftChanged event action.

This method allows you to specify an action that will be executed when the control's RightToLeftChanged event is triggered.


myControl.ONRightToLeftChanged(c => AlertBox.Show($"{c.Name} RightToLeft changed"));

Static member OnSizeChanged<TControl>(control, action)

Attaches an action to be executed when the Size property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Size property changes.

Returns: TControl. The control with the attached SizeChanged event action.

This method allows you to specify an action that will be executed when the control's SizeChanged event is triggered.


myControl.OnSizeChanged(c => AlertBox.Show($"{c.Name} size changed"));

Static member OnStyleChanged<TControl>(control, action)

Attaches an action to be executed when the style of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the style changes.

Returns: TControl. The control with the attached StyleChanged event action.

This method allows you to specify an action that will be executed when the control's StyleChanged event is triggered.


myControl.OnStyleChanged(c => AlertBox.Show($"{c.Name} style changed"));

Static member OnSwipe<TControl>(control, action)

Registers an action to be called when the Swipe event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, SwipeEventArgs>The action to perform when the swipe event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a swipe event handler to a control.


myControl.OnSwipe((ctrl, args) => { /* Handle swipe */ });

Static member OnTabIndexChanged<TControl>(control, action)

Attaches an action to be executed when the TabIndex property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the TabIndex property changes.

Returns: TControl. The control with the attached TabIndexChanged event action.

This method allows you to specify an action that will be executed when the control's TabIndexChanged event is triggered.


myControl.OnTabIndexChanged(c => AlertBox.Show($"{c.Name} tab index changed"));

Static member OnTabStopChanged<TControl>(control, action)

Attaches an action to be executed when the TabStop property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the TabStop property changes.

Returns: TControl. The control with the attached TabStopChanged event action.

This method allows you to specify an action that will be executed when the control's TabStopChanged event is triggered.


myControl.OnTabStopChanged(c => AlertBox.Show($"{c.Name} TabStop changed"));

Static member OnTextChanged<TControl>(control, action)

Attaches an action to be executed when the Text property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Text property changes.

Returns: TControl. The control with the attached TextChanged event action.

This method allows you to specify an action that will be executed when the control's TextChanged event is triggered.


myControl.OnTextChanged(c => AlertBox.Show($"{c.Name} text changed"));

Static member OnTouchCancel<TControl>(control, action)

Registers an action to be called when the TouchCancel event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, TouchEventArgs>The action to perform when the touch cancel event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a touch cancel event handler to a control.


myControl.OnTouchCancel((ctrl, args) => { /* Handle touch cancel */ });

Static member OnTouchEnd<TControl>(control, action)

Registers an action to be called when the TouchEnd event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, TouchEventArgs>The action to perform when the touch end event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a touch end event handler to a control.


myControl.OnTouchEnd((ctrl, args) => { /* Handle touch end */ });

Static member OnTouchMove<TControl>(control, action)

Registers an action to be called when the TouchMove event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, TouchEventArgs>The action to perform when the touch move event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a touch move event handler to a control.


myControl.OnTouchMove((ctrl, args) => { /* Handle touch move */ });

Static member OnTouchStart<TControl>(control, action)

Registers an action to be called when the TouchStart event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, TouchEventArgs>The action to perform when the touch start event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a touch start event handler to a control.


myControl.OnTouchStart((ctrl, args) => { /* Handle touch start */ });

Static member OnTrack<TControl>(control, action)

Registers an action to be called when the Track event is raised.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control on which to register the event handler.
actionAction<TControl, TrackEventArgs>The action to perform when the track event occurs.

Returns: TControl. The control with the event handler registered.

This method allows you to easily attach a track event handler to a control.


myControl.OnTrack((ctrl, args) => { /* Handle track */ });

Static member OnValidated<TControl>(control, action)

Attaches an action to be executed when the control is successfully validated.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the control is validated.

Returns: TControl. The control with the attached Validated event action.

This method allows you to specify an action that will be executed when the control's Validated event is triggered.


myControl.OnValidated(c => AlertBox.Show($"{c.Name} validated"));

Static member OnVisibleChanged<TControl>(control, action)

Attaches an action to be executed when the Visible property of the control changes.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl>The action to be executed when the Visible property changes.

Returns: TControl. The control with the attached VisibleChanged event action.

This method allows you to specify an action that will be executed when the control's VisibleChanged event is triggered.


myControl.OnVisibleChanged(c => AlertBox.Show($"{c.Name} visibility changed"));

Static member Padding<TControl>(control, padding)

Sets the padding for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the padding.
paddingPaddingThe padding to be applied to the control.

Returns: TControl. The control with the updated padding.

Static member Padding<TControl>(control, padding)

Sets the padding for the specified control using an array of integers.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the padding.
paddingInt32[]An array of integers representing the padding. Must be 1 (all), 2 (horizontal, vertical), or 4 (left, top, right, bottom).

Returns: TControl. The control with the updated padding.

This method allows setting the padding using different configurations of padding values.


myControl.Padding(5); // All sides
myControl.Padding(5, 10); // Horizontal and vertical
myControl.Padding(5, 10, 15, 20); // Left, top, right, bottom

Throws:

Static member Parent<TControl>(control, parent)

Sets the parent control for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the parent.
parentControlThe parent control to be assigned.

Returns: TControl. The control with the updated parent.

Static member ResetBindings<TControl>(control)

Resets data bindings on the control.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance whose bindings are to be reset.

Returns: TControl. The control instance after resetting bindings.

This method resets all data bindings for the control, refreshing the data displayed.

Static member RightToLeft<TControl>(control, rtl)

Sets the RightToLeft property for the specified control, determining the direction of text and layout.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the RightToLeft property.
rtlRightToLeftThe RightToLeft value to be applied to the control.

Returns: TControl. The control with the updated RightToLeft property.

Static member Scale<TControl>(control, factor)

Scales the control by the specified factor.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to scale.
factorSizeFThe scaling factor as a SizeF structure.

Returns: TControl. The control instance after scaling.

This method resizes the control by the specified scaling factor.

Static member Scale<TControl>(control, ratio)

Scales the control by the specified ratio.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to scale.
ratioSingleThe scaling ratio as a Single.

Returns: TControl. The control instance after scaling.

This method resizes the control by the specified ratio, maintaining aspect ratio.

Static member Scale<TControl>(control, dx, dy)

Scales the control by the specified horizontal and vertical factors.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to scale.
dxSingleThe horizontal scaling factor.
dySingleThe vertical scaling factor.

Returns: TControl. The control instance after scaling.

This method resizes the control by the specified horizontal and vertical scaling factors.

Static member ScrollControlIntoView<TControl>(control)

Scrolls the control into view within its parent container.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to scroll into view.

Returns: TControl. The control instance after scrolling into view.

This method ensures that the control is visible within its parent container by scrolling as necessary.

Static member ScrollControlIntoView<TControl>(control, alignX, alignY)

Scrolls the control into view within its parent container, aligning it according to the specified horizontal and vertical alignment.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to scroll into view.
alignXHorizontalAlignmentThe horizontal alignment to use.
alignYVerticalAlignmentThe vertical alignment to use.

Returns: TControl. The control instance after scrolling into view.

This method ensures that the control is visible within its parent container, aligning it according to the specified parameters.

Static member Select<TControl>(control, directed, forward)

Selects the control, optionally specifying the direction and focus behavior.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to select.
directedBooleanIndicates whether to select the control in a directed manner.
forwardBooleanIndicates whether to select the next control in the forward direction.

Returns: TControl. The control instance after selection.

This method selects the control and can optionally direct focus to the next or previous control.

Static member Selectable<TControl>(control, value)

ParameterTypeDescription
TControl
controlTControl
valueBoolean

Returns: TControl.

Static member SendToBack<TControl>(control)

Sends the control to the back of the z-order.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to send to the back.

Returns: TControl. The control instance after being sent to the back.

This method changes the z-order of the control so that it appears behind all other controls.

Static member SetBounds<TControl>(control, x, y, width, height)

Sets the bounds of the control to the specified location and size.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to modify.
xInt32The new x-coordinate of the control.
yInt32The new y-coordinate of the control.
widthInt32The new width of the control.
heightInt32The new height of the control.

Returns: TControl. The control instance after setting its bounds.

This method sets the position and size of the control within its parent container.

Static member SetTopLevel<TControl>(control, value)

Sets the control's top-level status.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to modify.
valueBooleanA boolean value indicating whether the control should be top-level.

Returns: TControl. The control instance after setting the top-level status.

This method sets whether the control is a top-level control.

Static member Show<TControl>(control)

Displays the control.

ParameterTypeDescription
TControlThe type of the control, constrained to Control.
controlTControlThe control instance to show.

Returns: TControl. The control instance after being shown.

This method makes the control visible.

Static member Size<TControl>(control, size)

Sets the size for the specified control using a Size object.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the size.
sizeSizeThe size to be applied to the control.

Returns: TControl. The control with the updated size.

Static member Size<TControl>(control, width, height)

Sets the size for the specified control using width and height values.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the size.
widthInt32The width of the control.
heightInt32The height of the control.

Returns: TControl. The control with the updated size.

Static member TabIndex<TControl>(control, tabIndex)

Sets the tab index for the specified control, determining the order of focus when navigating with the Tab key.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the tab index.
tabIndexInt32The tab index to be assigned to the control.

Returns: TControl. The control with the updated tab index.

Static member TabStop<TControl>(control, tabStop)

Sets the TabStop property for the specified control, determining whether the control is included in the tab order.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the TabStop property.
tabStopBooleanA boolean value indicating whether the control is included in the tab order. Default is true.

Returns: TControl. The control with the updated TabStop property.

Static member Tag<TControl>(control, tag)

Sets the tag for the specified control, allowing for the storage of additional data.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the tag.
tagObjectThe object to be stored as the tag.

Returns: TControl. The control with the updated tag.

Static member Text<TControl>(control, text)

Sets the text for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the text.
textStringThe text to be displayed by the control.

Returns: TControl. The control with the updated text.

Static member ToBack<TControl>(control)

Sends the control to the back of the z-order.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to be sent to the back.

Returns: TControl. The control after being sent to the back.

If the control does not have a parent at the time of invocation, it will be sent to the back once a parent is assigned.


myControl.ToBack();

Static member ToFront<TControl>(control)

Brings the control to the front of the z-order.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to be brought to the front.

Returns: TControl. The control after being brought to the front.

If the control does not have a parent at the time of invocation, it will be brought to the front once a parent is assigned.


myControl.ToFront();

Static member Top<TControl>(control, top)

Sets the top position for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the top position.
topInt32The new top position to be applied to the control.

Returns: TControl. The control with the updated top position.

Static member UserData<TControl>(control, name, value)

Sets user-defined data for the specified control using a key-value pair.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the user data.
nameStringThe key for the user data.
valueObjectThe value to be associated with the key.

Returns: TControl. The control with the updated user data.

This method allows you to store custom data associated with the control using a dictionary-like structure.

Static member UserData<TControl>(control, values)

Assigns dynamic user data properties to the specified control and returns the control instance.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which user data properties will be assigned.
valuesObjectA dynamic object containing property names and values to be added to the control's user data.

Returns: TControl. The same TControl instance with updated user data.

This extension method iterates through the properties of the values object and assigns each property and its value to the UserData dictionary of the specified control . The method then returns the modified control, allowing for fluent chaining.


var button = new Button();
button.UserData(new { MyName = "Save", IsPrimary = true });

Static member UseWaitCursor<TControl>(control, useWait)

Sets the UseWaitCursor property for the specified control, determining whether to use the wait cursor for the control and its children.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the UseWaitCursor property.
useWaitBooleanA boolean value indicating whether to use the wait cursor. Default is false.

Returns: TControl. The control with the updated UseWaitCursor property.

Static member Validating<TControl>(control, action)

Attaches an action to be executed during the Validating event of the control, allowing for custom validation logic.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control to which the action will be attached.
actionAction<TControl, CancelEventArgs>The action to be executed during validation, with the event arguments provided.

Returns: TControl. The control with the attached Validating event action.

This method allows you to specify an action that will be executed when the control's Validating event is triggered.


myControl.Validating((c, args) => AlertBox.Show($"{c.Name} is validating"));

Static member Visible<TControl>(control, visible)

Sets the visibility of the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the visibility.
visibleBooleanA boolean value indicating whether the control should be visible. Default is true.

Returns: TControl. The control with the updated visibility.

Static member Width<TControl>(control, width)

Sets the width for the specified control.

ParameterTypeDescription
TControlThe type of the control, which must inherit from Control.
controlTControlThe control for which to set the width.
widthInt32The new width to be applied to the control.

Returns: TControl. The control with the updated width.