ContextAttributes.Add メソッド
更新 : 2007 年 11 月
ContextAttributes コレクションに属性名と属性値のペアを追加します。
名前空間 : EnvDTE
アセンブリ : EnvDTE (EnvDTE.dll 内)
構文
'宣言
Function Add ( _
AttributeName As String, _
AttributeValue As String, _
Type As vsContextAttributeType _
) As ContextAttribute
'使用
Dim instance As ContextAttributes
Dim AttributeName As String
Dim AttributeValue As String
Dim Type As vsContextAttributeType
Dim returnValue As ContextAttribute
returnValue = instance.Add(AttributeName, _
AttributeValue, Type)
ContextAttribute Add(
string AttributeName,
string AttributeValue,
vsContextAttributeType Type
)
ContextAttribute^ Add(
String^ AttributeName,
String^ AttributeValue,
vsContextAttributeType Type
)
function Add(
AttributeName : String,
AttributeValue : String,
Type : vsContextAttributeType
) : ContextAttribute
パラメータ
AttributeName
型 : System.String必ず指定します。新しい属性の名前です。
AttributeValue
型 : System.String必ず指定します。新しい属性の値です。
Type
型 : EnvDTE.vsContextAttributeType必ず指定します。新しい属性の型を指定する vsContextAttributeType 定数。
戻り値
ContextAttribute オブジェクト。
解説
Add を使用すると、コレクション (コンテキスト バッグ) に新しい属性を追加したり、キーワードを作成したりできます。
メモ : |
---|
メソッドを呼び出しているコレクション オブジェクトの Type に vsContextAttributesGlobal が設定されている場合、このメソッドは失敗し、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
アクセス許可
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。