Compartir a través de


ContextAttributes.HighPriorityAttributes Property

Definition

Gets the High Priority attributes collection.

public:
 property EnvDTE::ContextAttributes ^ HighPriorityAttributes { EnvDTE::ContextAttributes ^ get(); };
[System.Runtime.InteropServices.DispId(6)]
public EnvDTE.ContextAttributes HighPriorityAttributes { [System.Runtime.InteropServices.DispId(6)] get; }
[<System.Runtime.InteropServices.DispId(6)>]
[<get: System.Runtime.InteropServices.DispId(6)>]
member this.HighPriorityAttributes : EnvDTE.ContextAttributes
Public ReadOnly Property HighPriorityAttributes As ContextAttributes

Property Value

A ContextAttributes collection.

Attributes

Examples

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  

Remarks

There is only one instance of this attributes collection. It is available only from the ContextAttributes collection. If the ContextAttributes collection is for a window, then HighPriorityAttributes returns nothing.

These attributes are always in effect, and they are the highest in the context bag precedence, resulting in matching topics going to the top of their respective categories.

Applies to