Export (0) Print
Expand All

ToolStripTextBox Class

Represents a text box in a ToolStrip that allows the user to enter text.

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

[ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.None|ToolStripItemDesignerAvailability.ToolStrip|ToolStripItemDesignerAvailability.MenuStrip|ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class ToolStripTextBox : ToolStripControlHost

The ToolStripTextBox type exposes the following members.

  NameDescription
Public methodToolStripTextBox()Initializes a new instance of the ToolStripTextBox class.
Public methodToolStripTextBox(Control)Initializes a new instance of the ToolStripTextBox class derived from a base control.
Public methodToolStripTextBox(String)Initializes a new instance of the ToolStripTextBox class with the specified name.
Top

  NameDescription
Public propertyAcceptsReturnGets or sets a value indicating whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the form.
Public propertyAcceptsTabGets or sets a value indicating whether pressing the TAB key in a multiline text box control types a TAB character in the control instead of moving the focus to the next control in the tab order.
Public propertyAccessibilityObjectGets the AccessibleObject assigned to the control. (Inherited from ToolStripItem.)
Public propertyAccessibleDefaultActionDescriptionGets or sets the default action description of the control for use by accessibility client applications. (Inherited from ToolStripItem.)
Public propertyAccessibleDescriptionGets or sets the description that will be reported to accessibility client applications. (Inherited from ToolStripItem.)
Public propertyAccessibleNameGets or sets the name of the control for use by accessibility client applications. (Inherited from ToolStripItem.)
Public propertyAccessibleRoleGets or sets the accessible role of the control, which specifies the type of user interface element of the control. (Inherited from ToolStripItem.)
Public propertyAlignmentGets or sets a value indicating whether the item aligns towards the beginning or end of the ToolStrip. (Inherited from ToolStripItem.)
Public propertyAllowDropGets or sets a value indicating whether drag-and-drop and item reordering are handled through events that you implement. (Inherited from ToolStripItem.)
Public propertyAnchorGets or sets the edges of the container to which a ToolStripItem is bound and determines how a ToolStripItem is resized with its parent. (Inherited from ToolStripItem.)
Public propertyAutoCompleteCustomSourceGets or sets a custom string collection to use when the AutoCompleteSource property is set to CustomSource.
Public propertyAutoCompleteModeGets or sets an option that controls how automatic completion works for the ToolStripTextBox.
Public propertyAutoCompleteSourceGets or sets a value specifying the source of complete strings used for automatic completion.
Public propertyAutoSizeGets or sets a value indicating whether the item is automatically sized. (Inherited from ToolStripItem.)
Public propertyAutoToolTipGets or sets a value indicating whether to use the Text property or the ToolTipText property for the ToolStripItem ToolTip. (Inherited from ToolStripItem.)
Public propertyAvailableGets or sets a value indicating whether the ToolStripItem should be placed on a ToolStrip. (Inherited from ToolStripItem.)
Public propertyBackColorGets or sets the background color for the control. (Inherited from ToolStripControlHost.)
Public propertyBackgroundImageInfrastructure. This property is not relevant to this class. (Overrides ToolStripControlHost.BackgroundImage.)
Public propertyBackgroundImageLayoutInfrastructure. This property is not relevant to this class. (Overrides ToolStripControlHost.BackgroundImageLayout.)
Public propertyBorderStyleGets or sets the border type of the ToolStripTextBox control.
Public propertyBoundsGets the size and location of the item. (Inherited from ToolStripItem.)
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyCanSelectGets a value indicating whether the control can be selected. (Inherited from ToolStripControlHost.)
Public propertyCanUndoGets a value indicating whether the user can undo the previous operation in a ToolStripTextBox control.
Public propertyCausesValidationGets or sets a value indicating whether the hosted control causes and raises validation events on other controls when the hosted control receives focus. (Inherited from ToolStripControlHost.)
Public propertyCharacterCasingGets or sets whether the ToolStripTextBox control modifies the case of characters as they are typed.
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public propertyContentRectangleGets the area where content, such as text and icons, can be placed within a ToolStripItem without overwriting background borders. (Inherited from ToolStripItem.)
Public propertyControlGets the Control that this ToolStripControlHost is hosting. (Inherited from ToolStripControlHost.)
Public propertyControlAlignGets or sets the alignment of the control on the form. (Inherited from ToolStripControlHost.)
Protected propertyDefaultAutoToolTipGets a value indicating whether to display the ToolTip that is defined as the default. (Inherited from ToolStripItem.)
Protected propertyDefaultDisplayStyleGets a value indicating what is displayed on the ToolStripItem. (Inherited from ToolStripItem.)
Protected propertyDefaultMarginGets the spacing, in pixels, between the ToolStripTextBox and adjacent items. (Overrides ToolStripItem.DefaultMargin.)
Protected propertyDefaultPaddingGets the internal spacing characteristics of the item. (Inherited from ToolStripItem.)
Protected propertyDefaultSizeGets the default size of the ToolStripTextBox. (Overrides ToolStripControlHost.DefaultSize.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyDismissWhenClickedGets a value indicating whether items on a ToolStripDropDown are hidden after they are clicked. (Inherited from ToolStripItem.)
Public propertyDisplayStyleInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyDockGets or sets which ToolStripItem borders are docked to its parent control and determines how a ToolStripItem is resized with its parent. (Inherited from ToolStripItem.)
Public propertyDoubleClickEnabledInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyEnabledGets or sets a value indicating whether the parent control of the ToolStripItem is enabled. (Inherited from ToolStripControlHost.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertyFocusedGets a value indicating whether the control has input focus. (Inherited from ToolStripControlHost.)
Public propertyFontGets or sets the font to be used on the hosted control. (Inherited from ToolStripControlHost.)
Public propertyForeColorGets or sets the foreground color of the hosted control. (Inherited from ToolStripControlHost.)
Public propertyHeightGets or sets the height, in pixels, of a ToolStripItem. (Inherited from ToolStripItem.)
Public propertyHideSelectionGets or sets a value indicating whether the selected text in the text box control remains highlighted when the control loses focus.
Public propertyImageInfrastructure. The image associated with the object. (Inherited from ToolStripControlHost.)
Public propertyImageAlignInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyImageIndexGets or sets the index value of the image that is displayed on the item. (Inherited from ToolStripItem.)
Public propertyImageKeyGets or sets the key accessor for the image in the ImageList that is displayed on a ToolStripItem. (Inherited from ToolStripItem.)
Public propertyImageScalingInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyImageTransparentColorThis property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyIsDisposedGets a value indicating whether the object has been disposed of. (Inherited from ToolStripItem.)
Public propertyIsOnDropDownGets a value indicating whether the container of the current Control is a ToolStripDropDown. (Inherited from ToolStripItem.)
Public propertyIsOnOverflowGets a value indicating whether the Placement property is set to Overflow. (Inherited from ToolStripItem.)
Public propertyLinesGets or sets the lines of text in a ToolStripTextBox control.
Public propertyMarginGets or sets the space between the item and adjacent items. (Inherited from ToolStripItem.)
Public propertyMaxLengthGets or sets the maximum number of characters the user can type or paste into the text box control.
Public propertyMergeActionGets or sets how child menus are merged with parent menus. (Inherited from ToolStripItem.)
Public propertyMergeIndexGets or sets the position of a merged item within the current ToolStrip. (Inherited from ToolStripItem.)
Public propertyModifiedGets or sets a value that indicates that the ToolStripTextBox control has been modified by the user since the control was created or its contents were last set.
Public propertyMultilineInfrastructure. This property is not relevant to this class.
Public propertyNameGets or sets the name of the item. (Inherited from ToolStripItem.)
Public propertyOverflowGets or sets whether the item is attached to the ToolStrip or ToolStripOverflowButton or can float between the two. (Inherited from ToolStripItem.)
Public propertyOwnerGets or sets the owner of this item. (Inherited from ToolStripItem.)
Public propertyOwnerItemGets the parent ToolStripItem of this ToolStripItem. (Inherited from ToolStripItem.)
Public propertyPaddingGets or sets the internal spacing, in pixels, between the item's contents and its edges. (Inherited from ToolStripItem.)
Protected propertyParentGets or sets the parent container of the ToolStripItem. (Inherited from ToolStripItem.)
Public propertyPlacementGets the current layout of the item. (Inherited from ToolStripItem.)
Public propertyPressedGets a value indicating whether the state of the item is pressed. (Inherited from ToolStripItem.)
Public propertyReadOnlyGets or sets a value indicating whether text in the ToolStripTextBox is read-only.
Public propertyRightToLeftGets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts. (Inherited from ToolStripControlHost.)
Public propertyRightToLeftAutoMirrorImageInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertySelectedGets a value indicating whether the item is selected. (Inherited from ToolStripControlHost.)
Public propertySelectedTextGets or sets a value indicating the currently selected text in the control.
Public propertySelectionLengthGets or sets the number of characters selected in theToolStripTextBox.
Public propertySelectionStartGets or sets the starting point of text selected in theToolStripTextBox.
Public propertyShortcutsEnabledGets or sets a value indicating whether the defined shortcuts are enabled.
Protected propertyShowKeyboardCuesGets a value indicating whether to show or hide shortcut keys. (Inherited from ToolStripItem.)
Public propertySiteGets or sets the site of the hosted control. (Inherited from ToolStripControlHost.)
Public propertySizeGets or sets the size of the ToolStripItem. (Inherited from ToolStripControlHost.)
Public propertyTagGets or sets the object that contains data about the item. (Inherited from ToolStripItem.)
Public propertyTextGets or sets the text to be displayed on the hosted control. (Inherited from ToolStripControlHost.)
Public propertyTextAlignInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyTextBoxGets the hosted TextBox control.
Public propertyTextBoxTextAlignGets or sets how text is aligned in a TextBox control.
Public propertyTextDirectionInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyTextImageRelationInfrastructure. This property is not relevant to this class. (Inherited from ToolStripControlHost.)
Public propertyTextLengthGets the length of text in the control.
Public propertyToolTipTextGets or sets the text that appears as a ToolTip for a control. (Inherited from ToolStripItem.)
Public propertyVisibleGets or sets a value indicating whether the item is displayed. (Inherited from ToolStripItem.)
Public propertyWidthGets or sets the width in pixels of a ToolStripItem. (Inherited from ToolStripItem.)
Public propertyWordWrapThis property is not relevant to this class.
Top

  NameDescription
Public methodAppendTextAppends text to the current text of the ToolStripTextBox.
Public methodClearClears all text from the ToolStripTextBox control.
Public methodClearUndoClears information about the most recent operation from the undo buffer of the ToolStripTextBox.
Public methodCopyCopies the current selection in the ToolStripTextBox to the Clipboard.
Protected methodCreateAccessibilityInstanceCreates a new accessibility object for the control. (Inherited from ToolStripControlHost.)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodCutMoves the current selection in the ToolStripTextBox to the Clipboard.
Public methodDeselectAllSpecifies that the value of the SelectionLength property is zero so that no characters are selected in the control.
Public methodDispose()Releases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the ToolStripControlHost and optionally releases the managed resources. (Inherited from ToolStripControlHost.)
Public methodDoDragDropBegins a drag-and-drop operation. (Inherited from ToolStripItem.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public methodFocusGives the focus to a control. (Inherited from ToolStripControlHost.)
Public methodGetCharFromPositionRetrieves the character that is closest to the specified location within the control.
Public methodGetCharIndexFromPositionRetrieves the index of the character nearest to the specified location.
Public methodGetCurrentParentRetrieves the ToolStrip that is the container of the current ToolStripItem. (Inherited from ToolStripItem.)
Public methodGetFirstCharIndexFromLineRetrieves the index of the first character of a given line.
Public methodGetFirstCharIndexOfCurrentLineRetrieves the index of the first character of the current line.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetLineFromCharIndexRetrieves the line number from the specified character position within the text of the control.
Public methodGetPositionFromCharIndexRetrieves the location within the control at the specified character index.
Public methodGetPreferredSizeRetrieves the size of a rectangular area into which a control can be fitted. (Overrides ToolStripControlHost.GetPreferredSize(Size).)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodInvalidate()Invalidates the entire surface of the ToolStripItem and causes it to be redrawn. (Inherited from ToolStripItem.)
Public methodInvalidate(Rectangle)Invalidates the specified region of the ToolStripItem by adding it to the update region of the ToolStripItem, which is the area that will be repainted at the next paint operation, and causes a paint message to be sent to the ToolStripItem. (Inherited from ToolStripItem.)
Protected methodIsInputCharDetermines whether a character is an input character that the item recognizes. (Inherited from ToolStripItem.)
Protected methodIsInputKeyDetermines whether the specified key is a regular input key or a special key that requires preprocessing. (Inherited from ToolStripItem.)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected methodOnAcceptsTabChangedRaises the AcceptsTabChanged event.
Protected methodOnAvailableChangedRaises the AvailableChanged event. (Inherited from ToolStripItem.)
Protected methodOnBackColorChangedRaises the BackColorChanged event. (Inherited from ToolStripItem.)
Protected methodOnBorderStyleChangedRaises the BorderStyleChanged event.
Protected methodOnBoundsChangedOccurs when the Bounds property changes. (Inherited from ToolStripControlHost.)
Protected methodOnClickRaises the Click event. (Inherited from ToolStripItem.)
Protected methodOnDisplayStyleChangedRaises the DisplayStyleChanged event. (Inherited from ToolStripItem.)
Protected methodOnDoubleClickRaises the DoubleClick event. (Inherited from ToolStripItem.)
Protected methodOnDragDropRaises the DragDrop event. (Inherited from ToolStripItem.)
Protected methodOnDragEnterRaises the DragEnter event. (Inherited from ToolStripItem.)
Protected methodOnDragLeaveRaises the DragLeave event. (Inherited from ToolStripItem.)
Protected methodOnDragOverRaises the DragOver event. (Inherited from ToolStripItem.)
Protected methodOnEnabledChangedRaises the EnabledChanged event. (Inherited from ToolStripItem.)
Protected methodOnEnterRaises the Enter event. (Inherited from ToolStripControlHost.)
Protected methodOnFontChangedRaises the FontChanged event. (Inherited from ToolStripItem.)
Protected methodOnForeColorChangedRaises the ForeColorChanged event. (Inherited from ToolStripItem.)
Protected methodOnGiveFeedbackRaises the GiveFeedback event. (Inherited from ToolStripItem.)
Protected methodOnGotFocusRaises the GotFocus event. (Inherited from ToolStripControlHost.)
Protected methodOnHideSelectionChangedRaises the HideSelectionChanged event.
Protected methodOnHostedControlResizeSynchronizes the resizing of the control host with the resizing of the hosted control. (Inherited from ToolStripControlHost.)
Protected methodOnKeyDownRaises the KeyDown event. (Inherited from ToolStripControlHost.)
Protected methodOnKeyPressRaises the KeyPress event. (Inherited from ToolStripControlHost.)
Protected methodOnKeyUpRaises the KeyUp event. (Inherited from ToolStripControlHost.)
Protected methodOnLayoutRaises the Layout event. (Inherited from ToolStripControlHost.)
Protected methodOnLeaveRaises the Leave event. (Inherited from ToolStripControlHost.)
Protected methodOnLocationChangedRaises the LocationChanged event. (Inherited from ToolStripItem.)
Protected methodOnLostFocusRaises the LostFocus event. (Inherited from ToolStripControlHost.)
Protected methodOnModifiedChangedRaises the ModifiedChanged event.
Protected methodOnMouseDownRaises the MouseDown event. (Inherited from ToolStripItem.)
Protected methodOnMouseEnterRaises the MouseEnter event. (Inherited from ToolStripItem.)
Protected methodOnMouseHoverRaises the MouseHover event. (Inherited from ToolStripItem.)
Protected methodOnMouseLeaveRaises the MouseLeave event. (Inherited from ToolStripItem.)
Protected methodOnMouseMoveRaises the MouseMove event. (Inherited from ToolStripItem.)
Protected methodOnMouseUpRaises the MouseUp event. (Inherited from ToolStripItem.)
Protected methodOnMultilineChangedRaises the MultilineChanged event.
Protected methodOnOwnerChangedRaises the OwnerChanged event. (Inherited from ToolStripItem.)
Protected methodOnOwnerFontChangedRaises the FontChanged event when the Font property has changed on the parent of the ToolStripItem. (Inherited from ToolStripItem.)
Protected methodOnPaintRaises the Paint event. (Inherited from ToolStripControlHost.)
Protected methodOnParentBackColorChangedRaises the BackColorChanged event. (Inherited from ToolStripItem.)
Protected methodOnParentChangedRaises the ParentChanged event. (Inherited from ToolStripControlHost.)
Protected methodOnParentEnabledChangedRaises the EnabledChanged event when the Enabled property value of the item's container changes. (Inherited from ToolStripItem.)
Protected methodOnParentForeColorChangedRaises the ForeColorChanged event. (Inherited from ToolStripItem.)
Protected methodOnParentRightToLeftChangedRaises the RightToLeftChanged event. (Inherited from ToolStripItem.)
Protected methodOnQueryContinueDragRaises the QueryContinueDrag event. (Inherited from ToolStripItem.)
Protected methodOnReadOnlyChangedRaises the ReadOnlyChanged event.
Protected methodOnRightToLeftChangedRaises the RightToLeftChanged event. (Inherited from ToolStripItem.)
Protected methodOnSubscribeControlEventsSubscribes events from the hosted control. (Overrides ToolStripControlHost.OnSubscribeControlEvents(Control).)
Protected methodOnTextChangedRaises the TextChanged event. (Inherited from ToolStripItem.)
Protected methodOnUnsubscribeControlEventsUnsubscribes events from the hosted control. (Overrides ToolStripControlHost.OnUnsubscribeControlEvents(Control).)
Protected methodOnValidatedRaises the Validated event. (Inherited from ToolStripControlHost.)
Protected methodOnValidatingRaises the Validating event. (Inherited from ToolStripControlHost.)
Protected methodOnVisibleChangedRaises the VisibleChanged event. (Inherited from ToolStripItem.)
Public methodPasteReplaces the current selection in the text box with the contents of the Clipboard.
Public methodPerformClickActivates the ToolStripItem when it is clicked with the mouse. (Inherited from ToolStripItem.)
Protected methodProcessCmdKeyProcesses a command key. (Inherited from ToolStripControlHost.)
Protected methodProcessDialogKeyProcesses a dialog key. (Inherited from ToolStripControlHost.)
Protected methodProcessMnemonicProcesses a mnemonic character. (Inherited from ToolStripControlHost.)
Public methodResetBackColorInfrastructure. This method is not relevant to this class. (Inherited from ToolStripControlHost.)
Public methodResetDisplayStyleInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetFontInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetForeColorInfrastructure. This method is not relevant to this class. (Inherited from ToolStripControlHost.)
Public methodResetImageInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetMarginInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetPaddingInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetRightToLeftInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodResetTextDirectionInfrastructure. This method is not relevant to this class. (Inherited from ToolStripItem.)
Public methodScrollToCaretScrolls the contents of the control to the current caret position.
Public methodSelect()Selects the item. (Inherited from ToolStripItem.)
Public methodSelect(Int32, Int32)Selects a range of text in the text box.
Public methodSelectAllSelects all text in the text box.
Protected methodSetBoundsSets the size and location of the item. (Inherited from ToolStripItem.)
Protected methodSetVisibleCoreSets the ToolStripItem to the specified visible state. (Inherited from ToolStripControlHost.)
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from ToolStripItem.)
Public methodUndoUndoes the last edit operation in the text box.
Top

  NameDescription
Public eventAcceptsTabChangedOccurs when the value of the AcceptsTab property changes.
Public eventAvailableChangedOccurs when the value of the Available property changes. (Inherited from ToolStripItem.)
Public eventBackColorChangedOccurs when the value of the BackColor property changes. (Inherited from ToolStripItem.)
Public eventBorderStyleChangedOccurs when the value of the BorderStyle property changes.
Public eventClickOccurs when the ToolStripItem is clicked. (Inherited from ToolStripItem.)
Public eventDisplayStyleChangedInfrastructure. This event is not relevant to this class. (Inherited from ToolStripControlHost.)
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public eventDoubleClickOccurs when the item is double-clicked with the mouse. (Inherited from ToolStripItem.)
Public eventDragDropOccurs when the user drags an item and the user releases the mouse button, indicating that the item should be dropped into this item. (Inherited from ToolStripItem.)
Public eventDragEnterOccurs when the user drags an item into the client area of this item. (Inherited from ToolStripItem.)
Public eventDragLeaveOccurs when the user drags an item and the mouse pointer is no longer over the client area of this item. (Inherited from ToolStripItem.)
Public eventDragOverOccurs when the user drags an item over the client area of this item. (Inherited from ToolStripItem.)
Public eventEnabledChangedOccurs when the Enabled property value has changed. (Inherited from ToolStripItem.)
Public eventEnterOccurs when the hosted control is entered. (Inherited from ToolStripControlHost.)
Public eventForeColorChangedOccurs when the ForeColor property value changes. (Inherited from ToolStripItem.)
Public eventGiveFeedbackOccurs during a drag operation. (Inherited from ToolStripItem.)
Public eventGotFocusOccurs when the hosted control receives focus. (Inherited from ToolStripControlHost.)
Public eventHideSelectionChangedOccurs when the value of the HideSelection property changes.
Public eventKeyDownOccurs when a key is pressed and held down while the hosted control has focus. (Inherited from ToolStripControlHost.)
Public eventKeyPressOccurs when a key is pressed while the hosted control has focus. (Inherited from ToolStripControlHost.)
Public eventKeyUpOccurs when a key is released while the hosted control has focus. (Inherited from ToolStripControlHost.)
Public eventLeaveOccurs when the input focus leaves the hosted control. (Inherited from ToolStripControlHost.)
Public eventLocationChangedOccurs when the location of a ToolStripItem is updated. (Inherited from ToolStripItem.)
Public eventLostFocusOccurs when the hosted control loses focus. (Inherited from ToolStripControlHost.)
Public eventModifiedChangedOccurs when the value of the Modified property changes.
Public eventMouseDownOccurs when the mouse pointer is over the item and a mouse button is pressed. (Inherited from ToolStripItem.)
Public eventMouseEnterOccurs when the mouse pointer enters the item. (Inherited from ToolStripItem.)
Public eventMouseHoverOccurs when the mouse pointer hovers over the item. (Inherited from ToolStripItem.)
Public eventMouseLeaveOccurs when the mouse pointer leaves the item. (Inherited from ToolStripItem.)
Public eventMouseMoveOccurs when the mouse pointer is moved over the item. (Inherited from ToolStripItem.)
Public eventMouseUpOccurs when the mouse pointer is over the item and a mouse button is released. (Inherited from ToolStripItem.)
Public eventMultilineChangedThis event is not relevant to this class.
Public eventOwnerChangedOccurs when the Owner property changes. (Inherited from ToolStripItem.)
Public eventPaintOccurs when the item is redrawn. (Inherited from ToolStripItem.)
Public eventQueryAccessibilityHelpOccurs when an accessibility client application invokes help for the ToolStripItem. (Inherited from ToolStripItem.)
Public eventQueryContinueDragOccurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled. (Inherited from ToolStripItem.)
Public eventReadOnlyChangedOccurs when the value of the ReadOnly property changes.
Public eventRightToLeftChangedOccurs when the RightToLeft property value changes. (Inherited from ToolStripItem.)
Public eventTextBoxTextAlignChangedOccurs when the value of the TextBoxTextAlign property changes.
Public eventTextChangedOccurs when the value of the Text property changes. (Inherited from ToolStripItem.)
Public eventValidatedOccurs after the hosted control has been successfully validated. (Inherited from ToolStripControlHost.)
Public eventValidatingOccurs while the hosted control is validating. (Inherited from ToolStripControlHost.)
Public eventVisibleChangedOccurs when the value of the Visible property changes. (Inherited from ToolStripItem.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIDropTarget.OnDragDropRaises the DragDrop event. (Inherited from ToolStripItem.)
Explicit interface implemetationPrivate methodIDropTarget.OnDragEnterRaises the DragEnter event. (Inherited from ToolStripItem.)
Explicit interface implemetationPrivate methodIDropTarget.OnDragLeaveRaises the DragLeave event. (Inherited from ToolStripItem.)
Explicit interface implemetationPrivate methodIDropTarget.OnDragOverRaises the DragOver event. (Inherited from ToolStripItem.)
Top

ToolStripTextBox is the TextBox optimized for hosting in a ToolStrip. A subset of the hosted control's properties and events are exposed at the ToolStripTextBox level, but the underlying TextBox control is fully accessible through the TextBox property.

The ToolStripTextBox control allows the user to enter text in an application. This control has additional functionality that is not found in the standard Windows text box control, including multiline editing.

Typically, a ToolStripTextBox control is used to display a single line of text or accept it as input. You can use the Multiline to enable multiple lines of text to be displayed or entered. Set the AcceptsTab and AcceptsReturn properties to true to allow greater text manipulation in a multiline ToolStripTextBox control.

You can limit the amount of text entered into a ToolStripTextBox control by setting the MaxLength property to a specific number of characters. Use the CharacterCasing property to allow the user to type only uppercase, only lowercase, or a combination of uppercase and lowercase characters into the ToolStripTextBox control.

To restrict text from being entered in a ToolStripTextBox control, you can create an event handler for the KeyDown event in order to validate each character entered in the control. You can also restrict all entry of data in a ToolStripTextBox control by setting the ReadOnly property to true.

The following code example demonstrates a ToolStripTextBox with various common property settings, including automatic completion options.

using System;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
    public class Form1 : Form
    {
        private ToolStrip toolStrip1;
        private ToolStripTextBox toolStripTextBox1;

        public Form1()
        {
            InitializeComponent();
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        private void InitializeComponent()
        {
            toolStrip1 = new System.Windows.Forms.ToolStrip();
            toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
            toolStrip1.SuspendLayout();
            SuspendLayout();
            //  
            // toolStrip1 
            // 
            toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            toolStripTextBox1});
            toolStrip1.Location = new System.Drawing.Point(0, 0);
            toolStrip1.Name = "toolStrip1";
            toolStrip1.Size = new System.Drawing.Size(292, 25);
            toolStrip1.TabIndex = 0;
            toolStrip1.Text = "toolStrip1";
            // This code example demonstrates the syntax for setting 
            // various ToolStripTextBox properties. 
            // 
            toolStripTextBox1.AcceptsReturn = true;
            toolStripTextBox1.AcceptsTab = true;
            toolStripTextBox1.AutoCompleteCustomSource.AddRange(new string[] {
            "This is line one.",
            "Second line.",
            "Another line."});
            toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
            toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            toolStripTextBox1.HideSelection = false;
            toolStripTextBox1.MaxLength = 32000;
            toolStripTextBox1.Name = "toolStripTextBox1";
            toolStripTextBox1.ShortcutsEnabled = false;
            toolStripTextBox1.Size = new System.Drawing.Size(100, 25);
            toolStripTextBox1.Text = "STRING1\r\nSTRING2\r\nSTRING3\r\nSTRING4";
            toolStripTextBox1.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            //  
            // Form1 
            // 
            ClientSize = new System.Drawing.Size(292, 273);
            Controls.Add(toolStrip1);
            Name = "Form1";
            toolStrip1.ResumeLayout(false);
            toolStrip1.PerformLayout();
            ResumeLayout(false);
            PerformLayout();

        }
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft