次の方法で共有


ContextAttributes.Add メソッド

ContextAttributes コレクションに属性名と属性値のペアを追加します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Function Add ( _
    AttributeName As String, _
    AttributeValue As String, _
    Type As vsContextAttributeType _
) As ContextAttribute
ContextAttribute Add(
    string AttributeName,
    string AttributeValue,
    vsContextAttributeType Type
)
ContextAttribute^ Add(
    String^ AttributeName, 
    String^ AttributeValue, 
    vsContextAttributeType Type
)
abstract Add : 
        AttributeName:string * 
        AttributeValue:string * 
        Type:vsContextAttributeType -> ContextAttribute
function Add(
    AttributeName : String, 
    AttributeValue : String, 
    Type : vsContextAttributeType
) : ContextAttribute

パラメーター

  • AttributeName
    型 : String

    必須。 新しい属性の名前です。

  • AttributeValue
    型 : String

    必須。 新しい属性の値です。

戻り値

型 : EnvDTE.ContextAttribute
ContextAttribute オブジェクト。

解説

Add を使用すると、コレクション (コンテキスト バッグ) に新しい属性を追加したり、キーワードを作成したりできます。

注意

メソッドを呼び出しているコレクション オブジェクトの TypevsContextAttributesGlobal が設定されている場合、このメソッドは失敗し、E_NOTIMPL が返されます。

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

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

ContextAttributes インターフェイス

EnvDTE 名前空間