MaskedTextBox::SelectedText Property

 

Gets or sets the current selection in the MaskedTextBox control.

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

public:
property String^ SelectedText {
	virtual String^ get() override;
	virtual void set(String^ value) override;
}

Property Value

Type: System::String^

The currently selected text as a String. If no text is currently selected, this property resolves to an empty string.

Selections retrieved using this property are formatted according to the control's formatting properties, such as Mask, FormatProvider, TextMaskFormat and CutCopyMaskFormat. Selections set using this property behave like a Paste operation: each character is matched against the mask, and the MaskInputRejected event is raised for invalid characters. If CutCopyMaskFormat is true, literals and prompt characters are allowed when setting SelectedText, and will be removed silently unless they violate the mask.

.NET Framework
Available since 2.0
Return to top
Show: