Gets a value that indicates whether the position of the mouse pointer corresponds to hit test results, which take element compositing into account. Gets a value indicating whether the mouse pointer is located over this element including child elements in the visual tree.
Gets or sets a value that indicates whether the text editing control is read-only to a user interacting with the control. Gets a value indicating whether the stylus is captured by this element. Gets a value that determines whether stylus capture is held by this element, or an element within the element bounds and its visual tree. Gets a value that indicates whether the stylus position corresponds to hit test results, which take element compositing into account.
Gets a value indicating whether the stylus cursor is located over this element including visual child elements. Gets or sets a value that indicates whether undo support is enabled for the text-editing control. Gets a value indicating whether this element is visible in the user interface UI. Gets or sets a graphics transformation that should apply to this element when layout is performed. Gets an enumerator for the logical child elements of the TextBox. Gets or sets the identifying name of the element.
The name provides a reference so that code-behind, such as event handler code, can refer to a markup element after it is constructed during processing by a XAML processor. Gets or sets the opacity factor applied to the entire UIElement when it is rendered in the user interface UI. Gets or sets an opacity mask, as a Brush implementation that is applied to any alpha-channel masking for the rendered content of this element.
Gets or sets a value that indicates whether this element incorporates style properties from theme styles. Gets or sets transform information that affects the rendering position of this element. Gets or sets the center point of any possible render transform declared by RenderTransform , relative to the bounds of the element. Gets or sets a value indicating the number of characters in the current selection in the text box. Gets or sets the opacity of the SelectionBrush. Gets or sets a value that determines whether rendering for this element should use device-specific pixel settings during rendering.
Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by using the TAB key. Gets or sets an arbitrary object value that can be used to store custom information about this element.
Gets a reference to the template parent of this element. This property is not relevant if the element was not created through a template. Gets all touch devices that are captured to this element or any child elements in its visual tree.
Gets or sets the unique identifier for localization for this element. Gets or sets a value that indicates whether layout rounding should be applied to this element's size and position during layout. Gets or sets the vertical alignment characteristics applied to this element when it is composed within a parent element such as a panel or items control.
Gets or sets the BitmapEffect value for the Visual. Gets or sets the BitmapEffectInput value for the Visual. Gets or sets the BitmapScalingMode for the Visual. Gets or sets a cached representation of the Visual. Gets or sets the clip region of the Visual as a Geometry value.
Gets or sets the edge mode of the Visual as an EdgeMode value. Gets or sets the bitmap effect to apply to the Visual. Gets or sets the opacity of the Visual. Gets or sets the Brush value that represents the opacity mask of the Visual. Gets or sets a clipped scrollable area for the Visual. Gets or sets the TextHintingMode of the Visual. Gets or sets the TextRenderingMode of the Visual. Gets or sets the Transform value for the Visual. Adds a routed event handler for a specified routed event, adding the handler to the handler collection on the current element.
Specify handledEventsToo as true to have the provided handler be invoked for routed event that had already been marked as handled by another element along the event route. Applies an animation to a specified dependency property on this element. Any existing animations are stopped and replaced with the new animation.
Applies an animation to a specified dependency property on this element, with the ability to specify what happens if the property already has a running animation. Builds the current template's visual tree if necessary, and returns a value that indicates whether the visual tree was rebuilt by this call. Positions child elements and determines a size for a UIElement.
Parent elements call this method from their ArrangeCore Rect implementation or a WPF framework-level equivalent to form a recursive layout update. This method constitutes the second pass of a layout update. Called to arrange and size the content of a Control object. Starts a specific animation for a specified animated property on this element, with the option of specifying what happens if the property already has a running animation. Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated.
Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started. Attempts to bring the provided region size of this element into view, within any scrollable regions it is contained within. Determines whether the calling thread has access to this DispatcherObject.
Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. Clears the local value of a read-only property.
The property to be cleared is specified by a DependencyPropertyKey. Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject. Copies the current selection of the text editing control to the Clipboard.
Removes the current selection from the text editing control and copies it to the Clipboard. Determines whether a provided DependencyObject is equivalent to the current DependencyObject. Searches for a resource with the specified key, and throws an exception if the requested resource is not found. Returns the base property value for the specified property on this element, disregarding any possible animated value from a running or stopped animation.
Returns the BindingExpression that represents the binding on the specified property. Gets a hash code for this DependencyObject. Returns a geometry for a clipping mask. The mask applies if the layout system attempts to arrange an element that is larger than the available display space. Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.
Returns the beginning character index for the next spelling error in the contents of the text box. Returns a SpellingError object associated with any spelling error at the specified character index.
Returns the beginning character index for any spelling error that includes the specified character. Returns the named element in the visual tree of an instantiated ControlTemplate. Gets the Type of the current instance. Returns the current effective value of a dependency property on this instance of a DependencyObject.
Overrides GetVisualChild Int32 , and returns a child at the specified index from a collection of child elements. Returns the input element within the current element that is at the specified coordinates, relative to the current element's origin. Invalidates the arrange state layout for the element. After the invalidation, the element will have its layout updated, which will occur asynchronously unless subsequently forced by UpdateLayout.
Invalidates the rendering of the element, and forces a complete new layout pass. OnRender DrawingContext is called after the layout cycle is completed.
Locks the most recent undo unit of the undo stack of the application. This prevents the locked unit from being merged with undo units that are added subsequently. Parent elements call this method from their own MeasureCore Size implementations to form a recursive layout update. Calling this method constitutes the first pass the "Measure" pass of a layout update. Implements basic measure-pass layout system behavior for FrameworkElement.
Creates a shallow copy of the current Object. Moves the keyboard focus away from this element and to another element in a provided traversal direction. Invoked whenever an unhandled ContextMenuClosing routed event reaches this class in its route. Implement this method to add class handling for this event. Called whenever an unhandled ContextMenuOpening routed event reaches this class in its route. Creates and returns an AutomationPeer object for the text box.
Invoked whenever an unhandled DragEnter attached routed event reaches an element derived from this class in its route. Invoked whenever an unhandled DragLeave attached routed event reaches an element derived from this class in its route.
Invoked whenever an unhandled DragOver attached routed event reaches an element derived from this class in its route.
Invoked whenever an unhandled GiveFeedback attached routed event reaches an element derived from this class in its route. Invoked whenever an unhandled GotFocus event reaches this element in its route.
Invoked whenever an unhandled GotKeyboardFocus attached routed event reaches an element derived from this class in its route. Invoked when an unhandled GotMouseCapture attached event reaches an element in its route that is derived from this class. Invoked when an unhandled GotStylusCapture attached event reaches an element in its route that is derived from this class.
Provides class handling for the GotTouchCapture routed event that occurs when a touch is captured to this element. Raises the Initialized event. This method is invoked whenever IsInitialized is set to true internally. Invoked when an unhandled IsKeyboardFocusedChanged event is raised on this element. Invoked when an unhandled IsMouseCapturedChanged event is raised on this element. Invoked when an unhandled IsStylusCapturedChanged event is raised on this element.
Invoked whenever an unhandled KeyDown attached routed event reaches an element derived from this class in its route. Invoked whenever an unhandled KeyUp attached routed event reaches an element derived from this class in its route. Raises the LostFocus event using the provided arguments.
Invoked whenever an unhandled LostKeyboardFocus attached routed event reaches an element derived from this class in its route. Invoked when an unhandled LostMouseCapture attached event reaches an element in its route that is derived from this class. Invoked when an unhandled LostStylusCapture attached event reaches an element in its route that is derived from this class.
Provides class handling for the LostTouchCapture routed event that occurs when this element loses a touch capture. Called when the ManipulationBoundaryFeedback event occurs. Called when the ManipulationCompleted event occurs. Called when the ManipulationDelta event occurs. Called when the ManipulationInertiaStarting event occurs. Called when the ManipulationStarted event occurs. Provides class handling for the ManipulationStarting routed event that occurs when the manipulation processor is first created.
Raises the MouseDoubleClick routed event. Invoked whenever an unhandled MouseDown attached routed event reaches an element derived from this class in its route. Invoked when an unhandled MouseEnter attached event is raised on this element. Invoked when an unhandled MouseLeave attached event is raised on this element. Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element.
Invoked when an unhandled MouseLeftButtonUp routed event reaches an element in its route that is derived from this class. Invoked whenever an unhandled MouseMove attached routed event reaches an element derived from this class in its route. Invoked when an unhandled MouseRightButtonDown routed event reaches an element in its route that is derived from this class.
Invoked when an unhandled MouseRightButtonUp routed event reaches an element in its route that is derived from this class. Invoked whenever an unhandled MouseUp event reaches an element derived from this class in its route.
Is called when a MouseWheel event is routed to this class or to a class that inherits from this class. Invoked when an unhandled PreviewDragEnter attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewDragLeave attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewDragOver attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewDrop attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewGiveFeedback attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewGotKeyboardFocus attached event reaches an element in its route that is derived from this class.
Called when the KeyDown occurs. Invoked when an unhandled PreviewKeyUp attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewKeyDown attached event reaches an element in its route that is derived from this class. Raises the PreviewMouseDoubleClick routed event.
Invoked when an unhandled PreviewMouseDown attached routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseLeftButtonDown routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseLeftButtonUp routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseMove attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewMouseRightButtonDown routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseRightButtonUp routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseUp attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewMouseWheel attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewQueryContinueDrag attached event reaches an element in its route that is derived from this class. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 7. Related Hot Network Questions. Occurs when AccessibleObject is providing help to accessibility applications. Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled.
Occurs when the value of the ReadOnly property has changed. Occurs when the value of the Region property changes. Occurs when the RightToLeft property value changes.
Occurs when the Size property value changes. Occurs when the TabIndex property value changes. Occurs when the TabStop property value changes. Occurs when the value of the TextAlign property has changed.
Occurs when the Text property value changes. Occurs when the Visible property value changes. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Text Box Class Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback? Namespace: System. Forms Assembly: System. Represents a Windows text box control. Note You must set the Multiline property to true to adjust the height of the TextBox control.
In this article. Inherited from TextBoxBase. Inherited from Control. Gets or sets the description of the control used by accessibility client applications. Gets or sets the name of the control used by accessibility client applications. Gets or sets the accessible role of the control. Gets or sets a value indicating whether the control can accept data that the user drags onto it. Gets or sets a value specifying the source of complete strings used for automatic completion. Gets or sets the background color of the control.
Gets or sets the border type of the text box control. Gets a value indicating whether the control can receive focus. Determines if events can be raised on the control. Gets a value indicating whether the control can be selected. Gets a value indicating whether the user can undo the previous operation in a text box control. Gets or sets a value indicating whether the control has captured the mouse.
Gets the rectangle that represents the client area of the control. Gets or sets the height and width of the client area of the control. Gets the name of the company or creator of the application containing the control. Inherited from Component. Gets or sets the shortcut menu associated with the control.
Gets the collection of controls contained within the control. Gets a value indicating whether the control has been created. Gets the required creation parameters when the control handle is created.
Gets or sets the cursor that is displayed when the mouse pointer is over the control. Gets the data bindings for the control. Gets or sets the default cursor for the control. Gets the space, in pixels, that is specified by default between controls. Gets the internal spacing, in pixels, of the contents of a control. Gets the default size of the control. Gets the DPI value for the display device where the control is currently being displayed. Gets the rectangle that represents the display area of the control.
Gets or sets a value indicating whether the control can respond to user interaction. Gets a value indicating whether the control has input focus. Gets or sets the font of the text displayed by the control.
Gets or sets the height of the font of the control. Gets or sets the foreground color of the control. Gets the window handle that the control is bound to. Gets a value indicating whether the control contains one or more child controls. Gets or sets the height of the control.
Gets or sets a value indicating whether the control is visible to accessibility applications. Gets a value indicating whether the control has been disposed of. Gets a value indicating whether the control has a handle associated with it. Gets a value indicating whether the control is mirrored. Gets a cached instance of the control's layout engine. Gets or sets the lines of text in a text box control.
Gets or sets the space between controls. Gets or sets a value indicating whether this is a multiline text box control. Gets or sets the name of the control.
Gets or sets the parent container of the control. Gets the preferred height for a text box. Gets the size of a rectangular area into which the control can fit. Gets the product name of the assembly containing the control. Gets the version of the assembly containing the control.
Gets or sets a value indicating whether text in the text box is read-only. Gets a value indicating whether the control is currently re-creating its handle. Gets or sets the window region associated with the control.
This property is now obsolete. Gets or sets a value indicating whether the control redraws itself when resized. Gets a value that determines the scaling of child controls.
Gets or sets a value indicating the currently selected text in the control. Gets or sets the number of characters selected in the editable portion of the text box. Gets or sets the number of characters selected in the text box. Gets or sets the starting point of text selected in the text box. Gets or sets a value indicating whether the defined shortcuts are enabled. Gets a value indicating whether the control should display focus rectangles.
Gets or sets the site of the control. Gets or sets the height and width of the control. Gets or sets the tab order of the control within its container. Gets or sets the object that contains data about the control. Gets the length of text in the control. Gets or sets a value indicating whether the control and all its child controls are displayed. Gets or sets the width of the control. AppendText String. Appends text to the current text of a text box. BeginInvoke Action. BeginInvoke Delegate.
BeginInvoke Delegate, Object[]. Brings the control to the front of the z-order. Clears all text from the text box control. Clears information about the most recent operation from the undo buffer of the text box.
Contains Control. Retrieves a value indicating whether the specified control is a child of the control. Copies the current selection in the text box to the Clipboard. Creates a new instance of the control collection for the control. Creates a handle for the control. CreateObjRef Type. Inherited from MarshalByRefObject. Moves the current selection in the text box to the Clipboard. DefWndProc Message.
Sends the specified message to the default window procedure. Destroys the handle associated with the control. Dispose Boolean. Begins a drag-and-drop operation. DrawToBitmap Bitmap, Rectangle. Supports rendering to the specified bitmap. EndInvoke IAsyncResult. Equals Object. Determines whether the specified object is equal to the current object. Inherited from Object. Retrieves the form that the control is on.
Sets input focus to the control. GetCharFromPosition Point. Retrieves the character that is closest to the specified location within the control. Retrieves the index of the character nearest to the specified location. GetChildAtPoint Point. Retrieves the child control that is located at the specified coordinates. Retrieves the index of the first character of a given line. Retrieves the index of the first character of the current line. Serves as the default hash function. Retrieves the line number from the specified character position within the text of the control.
GetNextControl Control, Boolean. Retrieves the next control forward or back in the tab order of child controls. Retrieves the location within the control at the specified character index. GetPreferredSize Size. Retrieves the size of a rectangular area into which a control can be fitted.
Retrieves the bounds within which the control is scaled. If the postal code must be a valid United States Zip code, you could call a Zip code Web service to validate the data entered by the user. The Validating event is supplied an object of type CancelEventArgs. If you determine that the control's data isn't valid, cancel the Validating event by setting this object's Cancel property to true.
If you don't set the Cancel property, Windows Forms will assume that validation succeeded for that control and raise the Validated event.
For a code example that validates an email address in a TextBox , see the Validating event reference. Validation is useful when you have bound your controls to a data source, such as a database table. By using validation, you can make sure that your control's data satisfies the format required by the data source, and that it doesn't contain any special characters such as quotation marks and back slashes that might be unsafe.
When you use data binding, the data in your control is synchronized with the data source during execution of the Validating event. If you cancel the Validating event, the data won't be synchronized with the data source. If you have custom validation that takes place after the Validating event, it won't affect the data binding.
For example, if you have code in a Validated event that attempts to cancel the data binding, the data binding will still occur. In this case, to perform validation in the Validated event, change the control's Binding. Never , and add your-control. WriteValue to your validation code. So when does a control's data get validated? This is up to you, the developer.
You can use either implicit or explicit validation, depending on the needs of your application. The implicit validation approach validates data as the user enters it. Validate the data by reading the keys as they're pressed, or more commonly whenever the user takes the input focus away from the control.
0コメント