Help2.DisplayTopicFromKeyword(String) 方法

定义

使用 K 关键字索引执行查找。

public:
 void DisplayTopicFromKeyword(System::String ^ pszKeyword);
public:
 void DisplayTopicFromKeyword(Platform::String ^ pszKeyword);
void DisplayTopicFromKeyword(std::wstring const & pszKeyword);
[System.Runtime.InteropServices.DispId(9)]
public void DisplayTopicFromKeyword (string pszKeyword);
[<System.Runtime.InteropServices.DispId(9)>]
abstract member DisplayTopicFromKeyword : string -> unit
Public Sub DisplayTopicFromKeyword (pszKeyword As String)

参数

pszKeyword
String

要查找和显示的帮助主题的 K 关键字索引。

实现

属性

示例

使用创建外接程序, Visual Studio Visual C# 如 如何:创建外接程序中所述。 添加对 Microsoft.VisualStudio.VSHelpMicrosoft.VisualStudio.VSHelp80 和的引用 System.Windows.Forms 。 将 OnConnection Connect.cs 文件中方法中的代码替换为以下代码。 按照 如何:编译和运行自动化对象模型代码示例中所述运行代码示例。

using System;  
using Extensibility;  
using EnvDTE;  
using EnvDTE80;  
using Microsoft.VisualStudio.VSHelp;  
using Microsoft.VisualStudio.VSHelp80;  
using System.Windows.Forms;  

public void OnConnection(object application,  
ext_ConnectMode connectMode, object addInInst, ref Array custom)  
{  
    _applicationObject = (DTE2)application;  
    _addInInstance = (AddIn)addInInst;  
    HelpDisplayFromKeywordExample(_applicationObject);  
}  

public void HelpDisplayFromKeywordExample(DTE2 dte)  
{  
    // This opens Document Explorer and   
    // displays the topic specified  
    // by the K keyword.  
    try  
    {  
        Microsoft.VisualStudio.VSHelp80.Help2 help2 =  
(Microsoft.VisualStudio.VSHelp80.Help2)_applicationObject.GetObject ("Help2");  

        // Display the Arrays topic.  
        help2.DisplayTopicFromKeyword("arrays");  
    }  

    catch (SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

注解

如果只找到一个匹配项,则 "文档资源管理器" 将显示该主题。

适用于