IVsTextView.GetSelection 方法
如果有的話,則傳回對應至目前的選取範圍的文字範圍。
命名空間: Microsoft.VisualStudio.TextManager.Interop
組件: Microsoft.VisualStudio.TextManager.Interop (在 Microsoft.VisualStudio.TextManager.Interop.dll 中)
語法
'宣告
Function GetSelection ( _
<OutAttribute> ByRef piAnchorLine As Integer, _
<OutAttribute> ByRef piAnchorCol As Integer, _
<OutAttribute> ByRef piEndLine As Integer, _
<OutAttribute> ByRef piEndCol As Integer _
) As Integer
int GetSelection(
out int piAnchorLine,
out int piAnchorCol,
out int piEndLine,
out int piEndCol
)
int GetSelection(
[OutAttribute] int% piAnchorLine,
[OutAttribute] int% piAnchorCol,
[OutAttribute] int% piEndLine,
[OutAttribute] int% piEndCol
)
abstract GetSelection :
piAnchorLine:int byref *
piAnchorCol:int byref *
piEndLine:int byref *
piEndCol:int byref -> int
function GetSelection(
piAnchorLine : int,
piAnchorCol : int,
piEndLine : int,
piEndCol : int
) : int
參數
piAnchorLine
類型:Int32%[] out選取項目的錨定行位置。 依據使用者選取項目,這個值不一定是選取範圍中左上角的行。
piAnchorCol
類型:Int32%[] out錨點選取項目的資料行位置。 依據使用者選取項目,這個值不一定是在選取範圍的上方、 左邊的資料行位置。 Viewcol 座標可能包括虛擬空間。
piEndLine
類型:Int32%[] out將選取範圍的結尾行位置。 依據使用者選取項目,這個值不一定是較低的行選取範圍中。
piEndCol
類型:Int32%[] out選取範圍的的結束資料行位置。 依據使用者選取項目,這個值不一定是在選取範圍的低,對資料行位置。 Viewcol 座標可能包括虛擬空間。
傳回值
類型:Int32
如果此方法將會成功,則會傳回S_OK。如果失敗,它就會傳回錯誤碼。
備註
COM 簽章
從 textmgr.idl:
HRESULT IVsTextView::GetSelection(
[out] long *piAnchorLine,
[out] ViewCol *piAnchorCol,
[out] long *piEndLine,
[out] ViewCol *piEndCol
);
參數GetSelection可以是nullnull 參考 (即 Visual Basic 中的 Nothing)不需要這些判斷選取範圍。 要傳回資訊儲存在這個TextSpan結構,呼叫GetSelectionSpan方法。
![]() |
---|
錨點位置不一定都在 [文字] 檢視的左方或上方的位置。比方說,在一段 10 行中,使用者可能會錨定其第 10 行中的選取範圍,然後結束他們在第 1,行的選取項目,因此改回預期的錨定列順序。 |
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。