ITextRangeProvider.MoveEndpointByUnit 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將文本範圍的一個端點移動,將文件範圍內指定的文本單元數量移動。
public:
int MoveEndpointByUnit(System::Windows::Automation::Text::TextPatternRangeEndpoint endpoint, System::Windows::Automation::Text::TextUnit unit, int count);
public int MoveEndpointByUnit(System.Windows.Automation.Text.TextPatternRangeEndpoint endpoint, System.Windows.Automation.Text.TextUnit unit, int count);
abstract member MoveEndpointByUnit : System.Windows.Automation.Text.TextPatternRangeEndpoint * System.Windows.Automation.Text.TextUnit * int -> int
Public Function MoveEndpointByUnit (endpoint As TextPatternRangeEndpoint, unit As TextUnit, count As Integer) As Integer
參數
- endpoint
- TextPatternRangeEndpoint
移動的終點。
- unit
- TextUnit
移動的文字單元。
- count
- Int32
需要移動的單位數量。 正值則會推動終點前進。 負值則會往後移動。 0 值則沒有影響。
傳回
實際移動的單位數量,如果移動端點會落在文件的開頭或結尾,這可能比請求的數量還少。
備註
當需要遍歷文字範圍的內容時,在幕後需要一系列步驟,才能讓 Move 方法順利執行。
文字範圍已被正規化;意味著,文字範圍會折疊為Start 端點的退化範圍,使End 端點變得多餘。 此步驟是為了消除文字範圍跨
unit越邊界的情況中的歧義;例如,「{The U}RL https://www.microsoft.com/ is embedded in text」中,其中「{」和「}」為文字範圍的端點。產生的範圍會移動至 DocumentRange 中,向後到達所要求
unit界限的開頭。然後,範圍會從退化的範圍狀態通過將 End 端點移動到一個要求的
unit邊界來進行擴展。
調整範圍 透過移動與擴展調整範圍文字範圍如何調整 Move() 與 ExpandToEnclosingUnit() 的範例
MoveEndpointByUnit若給定TextUnit未被控制組支持,則 讓位給出的下一個較大TextUnit支持者。
從最小到最大單位的順序如下所示。