Represents an independent text box element that provides comprehensive text editing capabilities including auto-completion, scrolling, selection management, and input handling. This element serves as the core implementation for text box controls and extends ScrollViewElement<T> with specialized text editing functionality.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
public class RadTextBoxControlElement : ScrollViewElement<TextBoxViewElement>, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IBindableComponent, IComponent, IDisposable, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode, IPrimitiveElement, IShapedElement, IFillElement, IBorderElement, IBoxStyle, IBoxElement, IDrawFillElement, IImageElement, ITextPrimitive, ITextProvider
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementRadComponentElementRadItemUIItemBaseLightVisualElementScrollViewElement<TextBoxViewElement>RadTextBoxControlElement...
Derived Classes:
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadTextBoxControlElement class.
public RadTextBoxControlElement()
Properties
Gets or sets a value indicating whether pressing ENTER in a multiline TextBox element creates a new line of text in the element or activates the default button for the form.
public bool AcceptsReturn { get; set; }
true if ENTER key creates a new line; otherwise, false to activate the default button.
Gets or sets a value indicating whether pressing the TAB key in a multiline text box element types a TAB character in the element instead of moving the focus to the next element in the tab order.
public bool AcceptsTab { get; set; }
true if TAB key inserts a tab character; otherwise, false to move focus to next control.
Gets or sets a value specifying the source of complete items used for automatic completion.
public object AutoCompleteDataSource { get; set; }
The data source providing auto-completion suggestions, or null if using the AutoCompleteItems collection.
Gets or sets the auto complete display member.
public string AutoCompleteDisplayMember { get; set; }
The property name used to display text for auto-completion items.
Gets the auto complete drop down.
public RadPopupControlBase AutoCompleteDropDown { get; }
The popup control that hosts the auto-completion dropdown list.
Gets a value specifying the complete items used for automatic completion.
public RadListDataItemCollection AutoCompleteItems { get; }
The collection of items used for auto-completion when no data source is specified.
Gets or sets an option that controls how automatic completion works for the TextBox.
public AutoCompleteMode AutoCompleteMode { get; set; }
The auto-completion mode that determines how suggestions are presented to the user.
Gets a value indicating whether this text box can perform auto complete operation.
protected virtual bool CanPerformAutoComplete { get; }
true if auto-completion is enabled and the text box is single-line; otherwise, false.
Gets the associated caret.
public TextBoxControlCaret Caret { get; }
The text cursor element that indicates the insertion point.
Gets or sets the caret position.
public int CaretIndex { get; set; }
The zero-based index of the caret position within the text.
Gets or sets whether the TextBox element modifies the case of characters as they are typed.
public CharacterCasing CharacterCasing { get; set; }
The character casing mode applied to typed text.
Gets the clear button.
public LightVisualButtonElement ClearButton { get; }
The button element that allows users to quickly clear all text.
Gets or sets the associated context menu.
public RadContextMenu ContextMenu { get; set; }
The context menu displayed on right-click, or null if no context menu is assigned.
Gets or sets the maximum size of the auto-complete dropdown.
public Size DropDownMaxSize { get; set; }
The maximum size constraints for the dropdown, or Empty for no maximum size limit.
Gets or sets the minimum size of the auto-complete dropdown.
public Size DropDownMinSize { get; set; }
The minimum size constraints for the dropdown, or Empty for no minimum size limit.
Gets an instance of the corresponding embedded label.
public LightVisualElement EmbeddedLabel { get; }
The embedded label element displayed within the text box.
Gets or set the animation speed of the embedded label. The speed is an integer between 1(off) and 10(slowest) with default value of 8.
public int EmbeddedLabelAnimationSpeed { get; set; }
The animation speed from 1 (disabled) to 10 (slowest), with 8 as the default.
Gets or set the offset of the embedded label from the bottom border, when the label is down.
public float EmbeddedLabelBorderOffset { get; set; }
The offset distance in pixels from the bottom border when the label is in its lowered position.
Gets or sets the text of the embedded label.
public string EmbeddedLabelText { get; set; }
The text content displayed in the embedded label.
Gets or sets a value indicating whether the selected text in the text box control remains highlighted when the element loses focus.
public bool HideSelection { get; set; }
true if selection should be hidden when unfocused; otherwise, false to keep selection visible.
Gets or sets when the horizontal scroll bar should appear in a multiline TextBox element.
public ScrollState HorizontalScrollBarState { get; set; }
The visibility state of the horizontal scroll bar.
Represents the associated keyboard and mouse input handler.
public ITextBoxInputHandler InputHandler { get; set; }
The input handler responsible for processing user interactions.
Gets a value indicating whether this auto-complete drop down is open.
[Browsable(false)]
public bool IsAutoCompleteDropDownOpen { get; }
true if the auto-complete dropdown is currently displayed; otherwise, false.
Gets or sets a value indicating whether text in the text box is read-only.
public bool IsReadOnly { get; set; }
true if the text box is read-only and cannot be edited; otherwise, false.
Gets or sets a value indicating whether the caret is visible in read only mode.
public bool IsReadOnlyCaretVisible { get; set; }
true if the caret should be visible even when read-only; otherwise, false.
Gets or sets the lines of text in a text box element.
public string[] Lines { get; set; }
An array of strings representing each line of text in the text box.
Gets the auto-complete list element.
public RadTextBoxListElement ListElement { get; }
The list element that displays auto-completion suggestions.
Gets or sets the max count of visible items in auto-complete drop down.
public int MaxDropDownItemCount { get; set; }
The maximum number of items displayed simultaneously in the dropdown before scrolling is required.
Gets or sets the maximum number of characters the user can type or paste into the text box element.
public int MaxLength { get; set; }
The maximum number of characters allowed, or MaxValue for unlimited input.
Gets or sets a value indicating whether this is a multiline text box.
public bool Multiline { get; set; }
true if the text box accepts multiple lines of text; otherwise, false for single-line input.
Gets or sets the navigator of the text position.
public ITextBoxNavigator Navigator { get; set; }
The navigator responsible for text positioning and selection management.
Gets or sets the prompt text that is displayed when the text box contains no text.
public string NullText { get; set; }
The text to display when the text box is empty.
Gets or sets the color of the null text.
public Color NullTextColor { get; set; }
The color used to display the null text.
Gets the view element of the null text.
public TextBoxWrapPanel NullTextViewElement { get; }
The panel element that displays placeholder text when the text box is empty.
Gets or sets the character used to mask characters of a password in a single-line text box.
public virtual char PasswordChar { get; set; }
The character used to mask password input, or '\0' to display actual characters.
Gets or set whether to reposition the embedded label, when text box is empty.
public bool RepositionEmbeddedLabel { get; set; }
true if the embedded label should move when the text box becomes empty; otherwise, false.
Gets or sets a value indicating the currently selected text in the element.
public string SelectedText { get; set; }
The text currently selected by the user, or an empty string if no text is selected.
Gets or sets the color of the selection.
public Color SelectionColor { get; set; }
The background color used to highlight selected text.
Gets or sets the number of characters selected in the text box.
public int SelectionLength { get; set; }
The number of characters selected, or 0 if no text is selected.
Gets or sets the selection opacity.
public int SelectionOpacity { get; set; }
The opacity level of the selection highlight (0-255).
Gets or sets the starting point of text selected in the text box.
public int SelectionStart { get; set; }
The zero-based index of the first character in the current text selection.
Gets or sets a value indicating whether the clear button is shown.
public bool ShowClearButton { get; set; }
true if the clear button should be displayed; otherwise, false.
Gets or sets the visibility of the embedded label. It is recommended to set AutoSize to true, when using the embedded label.
public bool ShowEmbeddedLabel { get; set; }
true if the embedded label should be visible; otherwise, false.
Gets or sets a value indicating whether the null text will be shown when the control is focused and the text is empty.
[Browsable(false)]
public bool ShowNullText { get; set; }
true if null text should be displayed when focused and empty; otherwise, false.
Gets or sets the current text in the text box element.
public override string Text { get; set; }
Overrides:
Gets or sets how the text is horizontally aligned in the element.
public HorizontalAlignment TextAlign { get; set; }
The horizontal alignment of text within the text box.
Gets the length of text in the element.
public int TextLength { get; }
The total number of characters in the text box.
Gets or sets a value indicating whether the text in view should appear as the default password character.
public virtual bool UseSystemPasswordChar { get; set; }
true to use the system password character; otherwise, false to display actual characters.
Gets or sets when the vertical scroll bar should appear in a multiline TextBox element.
public ScrollState VerticalScrollBarState { get; set; }
The visibility state of the vertical scroll bar.
Methods
Appends text to the current text of a text box.
Arranges the content and child elements within the final allocated space, positioning text, images, and child elements.
Arranges the view element.
protected override void ArrangeViewElement(RectangleF viewElementRect)
The view element rect.
Overrides:
Clears all text from the text box element.
public void Clear()
Closes the auto-complete drop down.
public void CloseDropDown()
Closes the drop down.
public virtual void CloseDropDown(RadPopupCloseReason reason)
The reason for closing the dropdown.
Copies the current selection in the text box to the Clipboard.
public virtual bool Copy()
true if text was copied to the clipboard; otherwise, false.
Creates the auto-complete drop down.
protected virtual RadPopupControlBase CreateAutoCompleteDropDown()
A new instance of RadPopupControlBase for hosting the auto-completion dropdown.
Creates the caret of the text box element.
protected virtual TextBoxControlCaret CreateCaret()
A new instance of TextBoxControlCaret for text position indication.
Creates the child elements that comprise the text box control, including the view element, scrollbars, caret, and supporting components.
protected override void CreateChildElements()
Overrides:
Creates the clear button element that allows users to quickly clear all text from the text box.
protected virtual LightVisualButtonElement CreateClearButton()
A new LightVisualButtonElement configured as a clear button.
Creates the embedded label element that can be displayed within the text box control.
protected virtual LightVisualElement CreateEmbeddedLabel()
A new LightVisualElement configured as an embedded label.
Creates the auto-complete list element.
protected virtual RadTextBoxListElement CreateListElement()
A new instance of RadTextBoxListElement for displaying auto-completion suggestions.
Creates an instance of TextBoxWrapPanel used to display placeholder text when the text box is empty.
protected virtual TextBoxWrapPanel CreateNullTextViewElement()
A new TextBoxWrapPanel instance configured for null text display.
Moves the current selection in the text box to the Clipboard.
Deletes the selected text or character at the current position.
Deletes the selected text or character at the current position.
public virtual bool Delete(bool nextCharacter, bool isControlPressed)
If set to true, deletes the next character; otherwise, deletes the previous character.
If set to true and Control modifier key is pressed, deletes to the end of the word.
true if text was successfully deleted; otherwise, false.
Specifies that the value of the SelectionLength property is zero so that no characters are selected in the element.
public virtual bool DeselectAll()
true if the selection was successfully cleared; otherwise, false.
Disposes of unmanaged resources used by the text box control element.
protected override void DisposeUnmanagedResources()
Overrides:
Called when the DPI scale factor changes. Updates the scale factor and notifies child elements.
public override void DpiScaleChanged(SizeF scaleFactor)
The new DPI scale factor.
Overrides:
Gets the auto-complete drop down location.
protected virtual Point GetAutoCompleteDropDownLocation()
The screen coordinates where the auto-complete dropdown should be positioned.
Gets the text that is used as filter condition in auto-completion.
protected virtual string GetAutoCompleteTextCondition(TextPosition startPosition, TextPosition endPosition)
The start position of the text range.
endPositionTextPositionThe end position of the text range.
Returns:The text that will be used to filter auto-completion suggestions.
Gets the size of the auto-complete drop down.
protected virtual Size GetDropDownSize()
The calculated size for the auto-complete dropdown based on item count and constraints.
Gets the first position for auto-completion text within the view element.
protected virtual TextPosition GetFirstAutoCompletePosition()
The text position representing the start of auto-completion.
Gets the last position for auto-completion text within the view element.
protected virtual TextPosition GetLastAutoCompletePosition()
The text position representing the end of auto-completion.
Gets the lines of the text box element.
protected virtual string[] GetLines()
string[]
An array of strings representing each line in the text box.
Handles processing of suggested text changes for auto-completion functionality.
protected virtual void HandleSuggestedTextChanged(SuggestedTextChangedEventArgs e)
The suggested text changed event arguments.
Initializes the default field values for the text box control element.
protected override void InitializeFields()
Overrides:
Determines whether the specified key is an input key that should be processed by the text box.
protected override bool IsInputKey(InputKeyEventArgs e)
The input key event arguments containing key information.
Returns:true if the key should be processed as input; otherwise, false.
Overrides:
Determines whether the current position is valid for the auto-complete operation
protected virtual bool IsValidAutoCompletePosition()
true if [is valid auto complete position]; otherwise, false.
Measures the desired size of the element by calculating the space needed for content, padding, and borders.
protected override void MeasureViewElement(SizeF availableSize)
Overrides:
Called when the auto-complete dropdown is closed.
protected virtual void OnAutoCompleteDropDownClosed(RadAutoCompleteDropDownClosedEventArgs e)
The auto-complete dropdown closed event arguments.
Called when the bounds of the element have changed.
protected override void OnBoundsChanged(RadPropertyChangedEventArgs e)
The event arguments containing bound change information.
Overrides:
Called when the context menu is opening.
protected bool OnContextMenuOpening(RadContextMenu menu)
The context menu being opened.
Returns:true if the menu should be displayed; otherwise, false to cancel the operation.
Raises the ContextMenuOpening event.
protected virtual void OnContextMenuOpening(TreeBoxContextMenuOpeningEventArgs e)
The TreeBoxContextMenuOpeningEventArgs instance containing the event data.
Called when the element is double-clicked.
protected override void OnDoubleClick(EventArgs e)
The event arguments.
Overrides:
Raises the IMECompositionEnded event when Input Method Editor composition completes.
protected virtual void OnIMECompositionEnded()
Raises the IMECompositionResult event when Input Method Editor produces a result.
protected virtual void OnIMECompositionResult(string result)
The composition result text.
Raises the IMECompositionStarted event when Input Method Editor composition begins.
protected virtual void OnIMECompositionStarted()
Raises the KeyDown event.
protected override void OnKeyDown(KeyEventArgs e)
The key event arguments.
Overrides:
Raises the KeyPress event.
protected override void OnKeyPress(KeyPressEventArgs e)
The key press event arguments.
Overrides:
Raises the KeyUp event.
protected override void OnKeyUp(KeyEventArgs e)
The key event arguments.
Overrides:
Called when the element has been loaded and is ready for interaction.
protected override void OnLoaded()
Overrides:
Called when a mouse button is pressed down over the item.
protected override void OnMouseDown(MouseEventArgs e)
The mouse event arguments.
Overrides:
Called when the mouse enters the element bounds.
protected override void OnMouseEnter(EventArgs e)
The event arguments.
Overrides:
Called when the mouse leaves the element bounds.
protected override void OnMouseLeave(EventArgs e)
The event arguments.
Overrides:
Called when the mouse moves over the element.
protected override void OnMouseMove(MouseEventArgs e)
The mouse event arguments.
Overrides:
Called when a mouse button is released over the element.
protected override void OnMouseUp(MouseEventArgs e)
The mouse event arguments.
Overrides:
Called when the mouse wheel is scrolled over the element.
protected override void OnMouseWheel(MouseEventArgs e)
The mouse event arguments.
Overrides:
Called when a property of the element has changed.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
The property changed event arguments.
Overrides:
Called when the element is being unloaded from the visual tree.
protected override void OnUnloaded(ComponentThemableElementTree oldTree)
The component tree from which the element is being removed.
Overrides:
Overrides the text painting to prevent default text rendering since text is handled by the view element.
protected override void PaintText(IGraphics graphics)
The graphics context for painting.
Overrides:
Replaces the current selection in the text box with the contents of the Clipboard.
public virtual bool Paste()
true if text was pasted from the clipboard; otherwise, false.
Performs the auto-complete for concrete operation.
protected void PerformAutoComplete(EditOperation context)
The context.
Performs the auto complete override.
protected virtual void PerformAutoCompleteOverride(EditOperation context)
The context.
Redo the last undo action.
public virtual bool Redo()
true if an action was successfully redone; otherwise, false.
Scrolls the contents of the control to the current caret position.
public void ScrollToCaret()
Selects all text in the text box element.
public void SelectAll()
Sets the lines of the text box element.
protected virtual void SetLines(string[] value)
The array of strings to set as text lines.
Shows the drop down.
public virtual void ShowDropDown(Point location)
The screen location where the dropdown should appear.
Toggles the text primitive display (overridden to prevent default text rendering).
protected override void ToggleTextPrimitive(RadProperty property)
The property being toggled.
Overrides:
Events
Occurs when the context menu is opening.
public event TreeBoxContextMenuOpeningEventHandler ContextMenuOpening
Occurs when an instance of ITextBlock is created.
public event CreateTextBlockEventHandler CreateTextBlock
Fired when the Input Method Editor completes the composition.
public event EventHandler IMECompositionEnded
IMECompositionResult
EventHandler<IMECompositionResultEventArgs>
Fired when the Input Method Editor has a result ready. For languages like Korean this might happen before the composition has ended.
public event EventHandler<IMECompositionResultEventArgs> IMECompositionResult
Fired when the Input Method Editor starts the composition.
public event EventHandler IMECompositionStarted
Occurs when text selection is changed.
public event SelectionChangedEventHandler SelectionChanged
Occurs when text selection is changing.
public event SelectionChangingEventHandler SelectionChanging
Occurs when text block is formatting.
public event TextBlockFormattingEventHandler TextBlockFormatting