ITextView2.TryGetTextViewLineContainingBufferPosition Method

Definition

Attempts to get the ITextViewLine that contains the specified text buffer position.

C++
public:
 bool TryGetTextViewLineContainingBufferPosition(Microsoft::VisualStudio::Text::SnapshotPoint bufferPosition, [Runtime::InteropServices::Out] Microsoft::VisualStudio::Text::Formatting::ITextViewLine ^ % textViewLine);

Parameters

bufferPosition
SnapshotPoint

The text buffer position used to search for a text line.

textViewLine
ITextViewLine

Returns out the ITextViewLine requested.

Returns

True if succeeded, false otherwise.

Remarks

This method returns an ITextViewLine if it exists in the view.

If the line does not exist in the cache of formatted lines, it will be formatted and added to the cache.

The returned ITextViewLine could be invalidated by either a layout by the view or by subsequent calls to this method.

It is occasionally invalid to retrieve an ITextViewLine due to layouts or other events. Callers should be prepared to handle a failure.

Applies to

Proizvod Verzije
Visual Studio SDK 2019, 2022