ITextRange.Delete method

Applies to Windows and Windows Phone

Deletes text from the text range.

Syntax


int Delete(
  TextRangeUnit unit, 
  int count
)

Parameters

unit

Type: TextRangeUnit

The unit of text to delete.

count

Type: System.Int32 [.NET] | int32 [C++]

The number of units to delete. See Remarks.

Return value

Type: System.Int32 [.NET] | int32 [C++]

The number of units deleted. Deleting the text in a nondegenerate text range counts as one unit.

Remarks

If count is zero, this method deletes all text in the text range. Nothing is deleted if the text range is only an insertion point (that is, a degenerate range).

If count is not zero, and the range is an insertion point, | count | (absolute value of count) units are deleted in the logical direction given by the sign of count, where a positive value is toward the end of the story, and a negative value is toward the start of the story.

If count is not zero, and the range is nondegenerate (contains text), the text in the range is deleted regardless of the values of unit and count, resulting in an insertion point. Then, | count | - 1 units are deleted in the logical direction given by the sign of count.

The text in the range can also be deleted by assigning a null string to the range.

Deleting the CR results in the following behavior:

  • If you delete just the CR but the paragraph includes text, the CR is deleted, and the following paragraph gets the same paragraph formatting as the current one.
  • If you delete the CR as well as some, but not all, of the characters in the following paragraph, the characters left over from the current paragraph get the paragraph formatting of the following paragraph.
  • If you select to the end of a paragraph, but not the whole paragraph, the CR is not deleted.
  • If you delete the whole paragraph (from the beginning through the CR), you delete the CR as well (unless it is the final CR in the file).

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Text
Windows::UI::Text [C++]

Metadata

Windows.winmd

See also

ITextRange

 

 

Show:
© 2014 Microsoft. All rights reserved.