Share via


IXRTextBox::SetMaxLength (Compact 2013)

3/28/2014

This method sets the value that determines the maximum number of characters allowed for user input.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetMaxLength(
    int MaxLength
) = 0;

Parameters

  • MaxLength
    [in] An integer value that indicates the new maximum number of characters allowed for user input.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

If MaxLength is set to 0, it indicates that there is no restriction on the number of characters.

MaxLength only restricts the number of characters that a user can input. It does not restrict the programmatic input. If the number of characters programmatically added to the text box is greater than the value of pMaxLength, then the user can delete characters, but not add any. As soon as the number of characters is less than MaxLength, the user can add text again.

The user is able to undo previous actions and cause the text to exceed the value of MaxLength.

If the user pastes text into the text box that causes the number of characters to exceed MaxLength, then the last characters in the text box are deleted.

Surrogate characters are treated as one character for the purposes of determining text length. For more information about surrogate characters, see this Web site.

.NET Framework Equivalent

System.Windows.Controls.TextBox.MaxLength

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRTextBox
IXRTextBox::GetMaxLength