This documentation is archived and is not being maintained.

ToolStripControlHost.Control Property

Gets the Control that this ToolStripControlHost is hosting.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public Control Control { get; }

Property Value

Type: System.Windows.Forms.Control
The Control that this ToolStripControlHost is hosting.

The following code example demonstrates constructing a ToolStripControlHost control and sets a property on the wrapped control using the Control property. To run this example, paste the code into a form that contains a ToolStrip named toolStrip1 and call InitializeDateTimePickerHost from the form's constructor or the Load event handler.


		ToolStripControlHost dateTimePickerHost;

		private void InitializeDateTimePickerHost()
		{

			// Create a new ToolStripControlHost, passing in a control.
			dateTimePickerHost = new ToolStripControlHost(new DateTimePicker());

			// Set the font on the ToolStripControlHost, this will affect the hosted control.
			dateTimePickerHost.Font = new Font("Arial", 7.0F, FontStyle.Italic);

			// Set the Width property, this will also affect the hosted control.
			dateTimePickerHost.Width = 100;
			dateTimePickerHost.DisplayStyle = ToolStripItemDisplayStyle.Text;

			// Setting the Text property requires a string that converts to a 
			// DateTime type since that is what the hosted control requires.
			dateTimePickerHost.Text = "12/23/2005";

			// Cast the Control property back to the original type to set a 
			// type-specific property.
			((DateTimePicker)dateTimePickerHost.Control).Format = DateTimePickerFormat.Short;

			// Add the control host to the ToolStrip.
			toolStrip1.Items.Add(dateTimePickerHost);

		}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: