更新:2007 年 11 月
获取高优先级属性集合。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
ReadOnly Property HighPriorityAttributes As ContextAttributes
用法
Dim instance As ContextAttributes
Dim value As ContextAttributes
value = instance.HighPriorityAttributes
ContextAttributes HighPriorityAttributes { get; }
property ContextAttributes^ HighPriorityAttributes {
    ContextAttributes^ get ();
}
function get HighPriorityAttributes () : ContextAttributes
属性值
一个 ContextAttributes 集合。
备注
此属性集合只有一个实例。只能从 ContextAttributes 集合获得它。如果 ContextAttributes 集合是针对窗口的,则 HighPriorityAttributes 不返回任何值。
这些属性总是有效的,它们的上下文包的优先级最高,从而使匹配主题居于它们各自目录的顶部。
示例
    Sub HighPriorityAttributesExample()
        Dim cas As EnvDTE.ContextAttributes
        Dim ca As EnvDTE.ContextAttribute
        Try
            cas = DTE.ContextAttributes
            ' List all regular and high priority attributes.
            ListAttr(ca, cas)
            ' Add a new F1 keyword to the global high priority 
            ' attributes collection.
            cas.HighPriorityAttributes.Add("NewAttribute", _
            "NewF1Keyword", vsContextAttributeType. _
            vsContextAttributeLookupF1)
            ListAttr(ca, cas)
            ' Remove the new high priority attribute.
            cas.HighPriorityAttributes.Item(1).Remove()
            ListAttr(ca, cas)
        Catch ex As System.Exception
            MsgBox("ERROR: " & ex.Message)
        End Try
    End Sub
    Function ListAttr(ByVal ca As ContextAttribute, ByVal cas As _
    ContextAttributes)
        Dim msg As String
        Try
            ' List regular attributes, their first value, and their count.
            For Each ca In cas
                msg = msg & ca.Name & "  " & ca.Values(0) & vbCr
            Next
            cas.Refresh()
            MsgBox("All Attributes: " & vbCr & msg & "Count: " & _
            cas.Count)
            ' List high-priority attributes, their first value, 
            ' and their count.
            msg = ""
            For Each ca In cas.HighPriorityAttributes
                msg = msg & ca.Name & "  " & ca.Values(0) & vbCr
            Next
            cas.Refresh()
            MsgBox("High-Priority Attributes: " & vbCr & msg & "Count: " _
            & cas.HighPriorityAttributes.Count)
        Catch ex As System.Exception
            MsgBox("ERROR: " & ex.Message)
        End Try
    End Function
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。