Export (0) Print
Expand All
Cut
Run
Expand Minimize
This topic has not yet been rated - Rate this topic

Add Method (ContextAttributes Collection)

Visual Studio .NET 2003

Adds an attribute name/value pair to the collection.

[Visual Basic .NET]
Public Function Add( _
   AttributeName As String, _
   AttributeValue As String, _
   Type As vsContextAttributeType _
) As ContextAttribute
[Visual Basic 6]
Function Add( _
   AttributeName As String, _
   AttributeValue As String, _
   Type As vsContextAttributeType _
) As ContextAttribute
[C++]
HRESULT __stdcall Add(
   BSTR AttributeName,
   BSTR AttributeValue,
   vsContextAttributeType Type,
   /* [out, retval] */ ContextAttribute** retVal
);
[C#]
ContextAttribute Add(
   string AttributeName,
   string AttributeValue,
   vsContextAttributeType Type
);
[JScript .NET]
public function Add(
   AttributeName : String,
   AttributeValue : String,
   Type : vsContextAttributeType
) : ContextAttribute

Parameters

AttributeName
Required. The name of the new attribute.
AttributeValue
Required. The value of the new attribute.
Type
Required. A vsContextAttributeType constant specifying the type of new attribute.

Return Value

Returns a ContextAttribute object.

Remarks

Allows you to add a new attribute to the collection (context bag) or create keywords.

Note   If the collection object on which you are calling the method has ContextAttributes.Type set to vsContextAttributesGlobal, then this method fails with E_NOTIMPL.

Example

Sub AddExample()
   'Get a reference to Solution Explorer.
   Dim SolnEx As Window = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer)
   Dim CA As ContextAttribute

   ' List the current attributes associated with Solution Explorer.
   ListAttr(SolnEx, CA)

   ' Associate a new F1 keyword with Solution Explorer.
   SolnEx.ContextAttributes.Add("ANewKeyword", 900, vsContextAttributeType.vsContextAttributeLookupF1)
   ListAttr(SolnEx, CA)

   ' Delete the new F1 keyword from Solution Explorer.
   SolnEx.ContextAttributes.Item(3).Remove()
   ListAttr(SolnEx, CA)
End Sub

Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
   ' Support function for CATest(). Lists the current attributes    
   ' associated with Solution Explorer.
   Dim msg As String

   MsgBox("Number of context attributes in Solution Explorer: " & SolnEx.ContextAttributes.Count)
   For Each CA In SolnEx.ContextAttributes
      msg = msg & CA.Name & Chr(13)
   Next
   MsgBox(msg)
   msg = ""
End Sub

See Also

Applies To: Add Method (ContextAttributes Collection)

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.