获取或设置集合筛选器。
命名空间: Microsoft.VisualStudio.VSHelp80
程序集: Microsoft.VisualStudio.VSHelp80(在 Microsoft.VisualStudio.VSHelp80.dll 中)
语法
声明
Property Filter As String
string Filter { get; set; }
property String^ Filter {
String^ get ();
void set (String^ value);
}
abstract Filter : string with get, set
function get Filter () : String
function set Filter (value : String)
属性值
类型:String
返回包含筛选器名称的字符串。
示例
创建 Visual Studio 外接程序使用 Visual C# 如 如何:创建外接程序所述。 添加对 Microsoft.VisualStudio.VSHelp、 Microsoft.VisualStudio.VSHelp80和 System.Windows.Forms。 用下面的代码替换该 OnConnection 方法的代码在 Connect.cs 文件。 运行代码示例 如何:编译和运行自动化对象模型代码示例如中所述。
备注
,在运行此示例之前,请确保将 Visual Studio 帮助集合中的筛选器。否则该方法将返回空异常。
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;
HelpFilterExample(_applicationObject);
}
public void HelpFilterExample(DTE2 dte)
{
// This add-in displays a message box with the filter applied to
// the active Help collection.
// inIt then changes the filter
// and displays the Contents window of Document
// Explorer with the new filter applied.
try
{
Microsoft.VisualStudio.VSHelp80.Help2 help2 =
(Microsoft.VisualStudio.VSHelp80.Help2)_applicationObject.GetObject
("Help2");
// Display the name of the filter.
MessageBox.Show("The Help filter name is: "
help2.Filter.ToString());
// Set the filter to Visual C#.
help2.Filter = "Visual C#";
// Set the focus to the Contents window and
// open Document Explorer.
help2.Contents();
}
catch (SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。