Class 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.
Inheritance
Inherited Members
Namespace: Telerik.WinControls
Assembly: Telerik.WinControls.dll
Syntax
public class RadHostItem : RadItem, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IComponent, IDisposable, IBindableComponent, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode
Remarks
RadHostItem enables any standard Windows Forms control (such as TextBox, ComboBox, DateTimePicker, or custom user controls) to be embedded within the Telerik element tree, participating in layout management, theming, and event routing while maintaining their native functionality.
The hosted control can be any descendant of the System.Windows.Forms.Control class with no restrictions. RadHostItem handles proper sizing, positioning, and lifecycle management of the hosted control, including focus management, validation events, and parent-child relationship maintenance.
Common use cases include integrating legacy Windows Forms controls into modern Telerik interfaces, hosting specialized controls within Telerik containers, and creating hybrid layouts that combine TPF elements with traditional Windows Forms controls for maximum flexibility.
Constructors
RadHostItem(Control)
Initializes a new instance of the RadHostItem class with the specified control to host.
Declaration
public RadHostItem(Control c)
Parameters
System.Windows.Forms.Control
c
The System.Windows.Forms.Control to be hosted within this RadHostItem. This can be any Windows Forms control or custom control. |
Remarks
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.
Fields
RadHostItemLastStateKey
This constant is used internally.
Declaration
protected const long RadHostItemLastStateKey = 8796093022208L
Field Value
System.Int64
|
Properties
CausesValidation
Gets or sets the CausesValidation property of the hosted control.
Declaration
public bool CausesValidation { get; set; }
Property Value
System.Boolean
|
Remarks
Using this property is equivalent to using HostedControl.CausesValidation
ClipControl
Gets or sets a value that determines whether the hosted control should be clipped when it requires more space than available.
Declaration
public virtual bool ClipControl { get; set; }
Property Value
System.Boolean
|
Remarks
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.
Enabled
Gets or sets a value indicating whether the RadHostItem and its hosted control are enabled.
Declaration
public override bool Enabled { get; set; }
Property Value
System.Boolean
|
Overrides
Remarks
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.
HostedControl
Gets the instance of the hosted Windows Forms control.
Declaration
public Control HostedControl { get; }
Property Value
System.Windows.Forms.Control
The System.Windows.Forms.Control instance that is being hosted by this RadHostItem. |
Remarks
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 System.Windows.Forms.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.
RouteMessages
Gets or sets whether the mouse and keyboard messages from the hosted control can be routed to the owner control.
Declaration
public bool RouteMessages { get; set; }
Property Value
System.Boolean
|
Remarks
You can use Control to get the owner control.
To get the hosted control use HostedControl property.
Methods
ArrangeCore(RectangleF)
Declaration
protected override void ArrangeCore(RectangleF finalRect)
Parameters
System.Drawing.RectangleF
finalRect
|
Overrides
DisposeManagedResources()
Declaration
protected override void DisposeManagedResources()
Overrides
DpiScaleChanged(SizeF)
Declaration
public override void DpiScaleChanged(SizeF scaleFactor)
Parameters
System.Drawing.SizeF
scaleFactor
|
Overrides
EnsureHostedControl()
Declaration
protected void EnsureHostedControl()
Focus()
Attempts to set focus to the hosted control.
Declaration
public override bool Focus()
Returns
System.Boolean
|
Overrides
Remarks
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.
InitializeFields()
MeasureOverride(SizeF)
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
|
Returns
System.Drawing.SizeF
|
Overrides
OnElementTreeChanged(ComponentThemableElementTree)
Declaration
protected override void OnElementTreeChanged(ComponentThemableElementTree previousTree)
Parameters
ComponentThemableElementTree
previousTree
|
Overrides
OnGotFocus(EventArgs)
Declaration
protected virtual void OnGotFocus(EventArgs e)
Parameters
System.EventArgs
e
|
OnLoaded()
OnLostFocus(EventArgs)
Declaration
protected virtual void OnLostFocus(EventArgs e)
Parameters
System.EventArgs
e
|
OnPropertyChanged(RadPropertyChangedEventArgs)
Declaration
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
Parameters
RadPropertyChangedEventArgs
e
|
Overrides
OnTransformationInvalidated()
Declaration
protected override void OnTransformationInvalidated()
Overrides
OnTunnelEvent(RadElement, RoutedEventArgs)
Declaration
protected override void OnTunnelEvent(RadElement sender, RoutedEventArgs args)
Parameters
RadElement
sender
|
RoutedEventArgs
args
|
Overrides
OnValidated(EventArgs)
Declaration
protected virtual void OnValidated(EventArgs e)
Parameters
System.EventArgs
e
|
OnValidating(CancelEventArgs)
Declaration
protected virtual void OnValidating(CancelEventArgs e)
Parameters
System.ComponentModel.CancelEventArgs
e
|
SyncBoundsWithHostedControl()
Declaration
protected virtual void SyncBoundsWithHostedControl()
SyncFont(Font)
Declaration
protected virtual void SyncFont(Font font)
Parameters
System.Drawing.Font
font
|
UpdateControlVisibility()
Updates the visibility, which is bound to the item's current IsVisible state, of the hosted control.
Declaration
public void UpdateControlVisibility()
Events
GotFocus
Occurs when the element recieves focus.
Declaration
public event EventHandler GotFocus
Event Type
System.EventHandler
|
LostFocus
Occurs when the element loses focus.
Declaration
public event EventHandler LostFocus
Event Type
System.EventHandler
|
Validated
Corresponds to the hosted control's Validated event
Declaration
public event EventHandler Validated
Event Type
System.EventHandler
|
Validating
Corresponds to the hosted control's Validating event
Declaration
public event CancelEventHandler Validating
Event Type
System.ComponentModel.CancelEventHandler
|