次の方法で共有


CaretPosition Structure

Represents the position of a caret in an ITextView.

Namespace:  Microsoft.VisualStudio.Text.Editor
Assembly:  Microsoft.VisualStudio.Text.UI (in Microsoft.VisualStudio.Text.UI.dll)

Syntax

'宣言
Public Structure CaretPosition
public struct CaretPosition
public value class CaretPosition
[<Sealed>]
type CaretPosition =  struct end
JScript supports the use of structures, but not the declaration of new ones.

The CaretPosition type exposes the following members.

Constructors

  Name Description
Public method CaretPosition Initializes a new instance of a CaretPosition.

Top

Properties

  Name Description
Public property Affinity Gets the affinity of the caret.
Public property BufferPosition Gets the position of the caret, corresponding to a gap between two characters in the ITextBuffer of the view.
Public property Point Gets the IMappingPoint that marks the position of the caret in the buffer.
Public property VirtualBufferPosition Gets the virtual buffer position as a VirtualSnapshotPoint.
Public property VirtualSpaces Gets the number of spaces past the physical end of the line of the caret position.

Top

Methods

  Name Description
Public method Equals Determines whether two CaretPosition objects are the same (Overrides ValueType.Equals(Object).)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Gets the hash code for the CaretPosition. (Overrides ValueType.GetHashCode().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Provides a string representation of the caret position. (Overrides ValueType.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Equality Determines whether two CaretPosition objects are the same.
Public operatorStatic member Inequality Determines whether two CaretPosition objects are different.

Top

Remarks

To get the caret's current position, you can listen to the PositionChanged event. (You can get the caret from the ITextView.)The ITextCaret class includes methods that allow you to move the caret to a different position.

Examples

For an example of finding the caret position, see Walkthrough: Displaying Matching Braces.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Text.Editor Namespace