RadHostItem
Represents a RadItem that can host any external Windows Forms control, providing seamless integration between standard Windows Forms controls and the Telerik Presentation Framework.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public class RadHostItem : RadItem, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IBindableComponent, IComponent, IDisposable, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementRadComponentElementRadItemRadHostItem...
Derived Classes:
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadHostItem class with the specified control to host.
public RadHostItem(Control c)
The Control to be hosted within this RadHostItem. This can be any Windows Forms control or custom control.
The constructor automatically synchronizes inheritable properties such as ForeColor, BackColor, and Font between the host item and the hosted control.
If the hosted control is a RadControl, special handling is applied to synchronize properties with the root element rather than the control directly.
Event wiring is automatically established to ensure proper integration between the hosted control and the Telerik element hierarchy.
Properties
Gets or sets the CausesValidation property of the hosted control.
public bool CausesValidation { get; set; }
Using this property is equivalent to using HostedControl.CausesValidation
Gets or sets a value that determines whether the hosted control should be clipped when it requires more space than available.
public virtual bool ClipControl { get; set; }
true if the hosted control should be clipped to fit within the available bounds; otherwise, false.
The default value is true.
When set to true, the hosted control will be automatically resized and clipped if it exceeds
the available space allocated to the RadHostItem. This ensures the control does not overlap with
other elements in the layout.
When set to false, the hosted control can extend beyond the bounds of the RadHostItem,
which may cause visual overlap with adjacent elements.
Gets or sets a value indicating whether the RadHostItem and its hosted control are enabled.
public override bool Enabled { get; set; }
true if both the RadHostItem and its hosted control are enabled; otherwise, false.
Overrides:
When this property is set, the enabled state is automatically synchronized with the hosted control.
Setting this to false will also disable the hosted control, preventing user interaction.
If the hosted control supports disabled appearance, it will be rendered accordingly.
Gets the instance of the hosted Windows Forms control.
public Control HostedControl { get; }
The Control instance that is being hosted by this RadHostItem.
This property provides direct access to the Windows Forms control that is hosted within the RadHostItem. The hosted control maintains its native functionality while being integrated into the Telerik element tree.
The hosted control can be any descendant of the Control class, including standard Windows Forms controls, third-party controls, or custom user controls.
Changes to the hosted control's properties should be made through this property or through the RadHostItem's synchronized properties to ensure proper integration with the TPF framework.
Gets or sets whether the mouse and keyboard messages from the hosted control can be routed to the owner control.
public bool RouteMessages { get; set; }
You can use Control to get the owner control.
To get the hosted control use HostedControl property.
Methods
Arranges the hosted control within the final layout rectangle, handling size synchronization.
protected override void ArrangeCore(RectangleF finalRect)
The final area within which this element should arrange its hosted control.
Overrides:
Releases managed resources used by this element, including disposing the hosted control.
protected override void DisposeManagedResources()
Overrides:
Called when the DPI scaling changes, updating the font synchronization for the hosted control.
public override void DpiScaleChanged(SizeF scaleFactor)
The new DPI scale factor.
Overrides:
Ensures the hosted control is properly registered with the component tree handler.
protected void EnsureHostedControl()
Attempts to set focus to the hosted control.
public override bool Focus()
true if the hosted control successfully received focus; otherwise, false.
Overrides:
This method attempts to set focus to the hosted control. If the hosted control implements IComponentTreeHandler, the focus request is routed through the interface. Otherwise, the default focus behavior is applied.
Initializes the fields of this instance with their default values.
protected override void InitializeFields()
Overrides:
Measures the size required by the hosted control and returns the desired size.
Called when the element tree changes, handling registration and unregistration of the hosted control.
protected override void OnElementTreeChanged(ComponentThemableElementTree previousTree)
The previous element tree that this element was part of.
Overrides:
Called when the element is loaded and ready for display operations.
protected override void OnLoaded()
Overrides:
Called when a property value has changed, handling synchronization of properties between the RadHostItem and the hosted control.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
The property changed event arguments.
Overrides:
Called when transformation is invalidated, synchronizing bounds with the hosted control.
protected override void OnTransformationInvalidated()
Overrides:
Called when a tunnel event is received, handling layout suspension/resumption for the hosted control.
protected override void OnTunnelEvent(RadElement sender, RoutedEventArgs args)
The element that raised the event.
argsRoutedEventArgsThe routed event arguments.
Overrides:
Raises the Validating event.
protected virtual void OnValidating(CancelEventArgs e)
A CancelEventArgs that contains the event data.
Synchronizes the bounds of the hosted control with the RadHostItem's current position and size.
protected virtual void SyncBoundsWithHostedControl()
Synchronizes the font of the hosted control with the RadHostItem's font, applying DPI scaling if necessary.
protected virtual void SyncFont(Font font)
The font to synchronize with the hosted control.
Updates the visibility, which is bound to the item's current IsVisible state, of the hosted control.
public void UpdateControlVisibility()
Events
Occurs when the element receives focus.
[Browsable(false)]
public event EventHandler GotFocus
Occurs when the element loses focus.
[Browsable(false)]
public event EventHandler LostFocus
Corresponds to the hosted control's Validated event.
public event EventHandler Validated
Corresponds to the hosted control's Validating event.
public event CancelEventHandler Validating