BaseUserControl Class

A base class for user controls that provides some additional functionality compared to UserControl.

Definition

Namespace: KGySoft.WinForms.Controls
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public class BaseUserControl : UserControl
Inheritance
Object    MarshalByRefObject    Component    Control    ScrollableControl    ContainerControl    UserControl    BaseUserControl
Derived

Remarks

The BaseUserControl class provides the following additional features:

Constructors

BaseUserControl Initializes a new instance of the BaseUserControl class.

Properties

CommandBindings Gets the command bindings of this user control. Being a WinFormsCommandBindingsCollection, the Add methods also add the PropertyCommandStateUpdater to the created bindings.
See the GitHub documentation for details.
DynamicStringLocalization Gets or sets the dynamic string localization strategy of the user control. It allows using potentially auto-generated string resources from .resx files.

See the online help of the BaseForm.DynamicStringLocalization property for an example.
IsDesignMode Gets whether the user control is in design mode. Unlike the DesignMode property, this property works even during initialization.
IsLoaded Gets whether the user control has already been loaded. This property is after the Load event is raised for the first time, and remains even if the handle is recreated (e.g. because RightToLeft changes). Can be useful if you override the OnLoad method, and you want to avoid executing some initialization more than once.

Methods

ApplyResources Applies the resources of the user control. The default implementation just calls the ApplyStringResources method. Called when the user control is loaded for the first time. In a derived control, this method can be overridden to apply additional (non-string) resources, and it can be called whenever the resources should be re-applied, e.g. when the display language changes.
ApplyStringResources Applies the string resources of the user control. If the DynamicStringLocalization property is not set to Disabled, and this user control has no parent form or a parent user control that has a non-disabled DynamicStringLocalization mode, the default implementation just calls the LocalizationHelper.ApplyStringResources method. In a derived control, this method can be overridden to apply a custom string localization, and it can be called whenever the form's string resources should be re-applied, e.g. when the display language changes.
DisposeReleases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.
(Overrides ContainerControlDispose(Boolean))
InvokeOnUIThread Invokes the specified callback on the thread that the control was created on.
OnDynamicStringLocalizationChanged Raises the DynamicStringLocalizationChanged event.
OnLoadRaises the Load event.
(Overrides UserControlOnLoad(EventArgs))

Events

DynamicStringLocalizationChanged Occurs when the DynamicStringLocalization property has changed.

Extension Methods

GetFormatFlags Gets the formatting flags for the text of a custom drawn control.
(Defined by ControlExtensions)
GetScale Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
(Defined by ScaleHelper)
GetScrollBarSize Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
(Defined by ScaleHelper)
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
(Defined by ScaleHelper)
ScaleHeight Scales the specified height by the vertical scale factor of the control.
(Defined by ScaleHelper)
ScaleSize Scales the specified size by the scale factor of the control.
(Defined by ScaleHelper)
ScaleWidth Scales the specified width by the horizontal scale factor of the control.
(Defined by ScaleHelper)
SetControlEnabled Sets the Enabled property of the child controls within the specified root control, or the Enabled property of the specified control itself, if it is not a recognized container control. By this way pages of a TabControl will remain selectable, a SplitContainer remains resizable, etc.
(Defined by ControlExtensions)
SetControlReadonly Recursively sets the read-only state in the children of the specified root control. Affects TextBoxBase and IReadOnlyCapable instances.
(Defined by ControlExtensions)
SetDoubleBuffered Sets the double buffered state of a control
(Defined by ControlExtensions)
SetStyle Sets a specified ControlStyles flag to either or . It calls the protected Control.SetStyle method on the specified control as if it was a public method.
(Defined by ControlExtensions)

See Also