IncrementalSearch.AppendCharAndSearch 方法

向 ISearch 模式添加一个字符并针对新字符串执行搜索。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
Function AppendCharAndSearch ( _
    Character As Short _
) As vsIncrementalSearchResult
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
abstract AppendCharAndSearch : 
        Character:int16 -> vsIncrementalSearchResult 
function AppendCharAndSearch(
    Character : short
) : vsIncrementalSearchResult

参数

  • Character
    类型:System.Int16
    一个转换为 Unicode 字符的短整型。

返回值

类型:EnvDTE80.vsIncrementalSearchResult
一个 vsIncrementalSearchResult 枚举。

备注

AppendCharAndSearch 向搜索模式添加一个新字符(请参见 Pattern 属性),然后沿着当前的方向搜索新模式。

如果找到了匹配项,则编辑器选定内容会移动到匹配项,而且会返回 Found 值。

如果找不到匹配项,则选定内容不更改,而且会返回 Failed 值。 新字符不会追加到失败的搜索模式。 若要用 AppendCharAndSearch 进一步执行搜索,则必须将错误的字符从该模式中移除。

使用 AscW() 函数为字符提供 Unicode 码位。

示例

Sub testIS()
    ' Set variables for text pane.
    Dim tp As EnvDTE80.TextPane2
    tp = CType(DTE.ActiveDocument.ActiveWindow.Object.ActivePane, _
    TextPane2)
    ' Start an incremental search forward from
    ' the current insertion point in the document.
    tp.IncrementalSearch.StartForward()
    ' Add the character "a" to the search pattern.
    tp.IncrementalSearch.AppendCharAndSearch(Asc("a"))
    ' Display the status of the search mode.
    'MsgBox("ISearch status: " & _
    tp.IncrementalSearch.IncrementalSearchModeOn.ToString)
    ' Perform incremental search using the pattern ("a").
    tp.IncrementalSearch.SearchWithLastPattern()
    ' After the search, exit incremental search mode.
    tp.IncrementalSearch.Exit()
End Sub

.NET Framework 安全性

请参见

参考

IncrementalSearch 接口

EnvDTE80 命名空间

其他资源

How to: Automate an Incremental Search

如何:对文档进行渐进式搜索