Windows2.Item 메서드
Windows 컬렉션의 인덱싱된 멤버를 반환합니다.
네임스페이스: EnvDTE80
어셈블리: EnvDTE80(EnvDTE80.dll)
구문
‘선언
Function Item ( _
index As Object _
) As Window
Window Item(
Object index
)
Window^ Item(
[InAttribute] Object^ index
)
abstract Item :
index:Object -> Window
function Item(
index : Object
) : Window
매개 변수
index
형식: Object필수입니다. 반환할 항목의 인덱스입니다.
반환 값
형식: Window
Window 개체
설명
Index에 전달된 값은 컬렉션의 개체에 대한 인덱스를 나타내는 정수입니다. 그러나 Index는 컬렉션 내의 개체를 나타내는 문자열 값이 될 수도 있습니다. 그러나 Item에 허용되는 정확한 값은 컬렉션과 해당 구현 방법에 따라 다릅니다.
Item 메서드는 컬렉션에서 인덱스 값에 해당하는 개체를 찾지 못하면 ArgumentException 예외를 throw합니다.
예제
이 예제에서는 Windows2 컬렉션에 있는 모든 항목의 캡션을 표시합니다.
이 예제를 추가 기능으로 실행하는 방법에 대한 자세한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.
Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
IterateItems(_applicationObject)
End Sub
Sub IterateItems(ByVal dte As DTE2)
Dim win As Windows2
win = CType(_applicationObject.Windows, EnvDTE80.Windows2)
Dim aString As String
aString = ""
Dim count As Integer
count = win.Count
Dim i As Integer
For i = 1 To count Step 1
aString = aString & "The window number " & i & _
" in the collection, has the caption: " & win.Item(i).Caption & vbCr
Next
MsgBox(aString)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
IterateItems(_applicationObject);
}
public void IterateItems(DTE2 dte)
{
Windows2 win;
win = (EnvDTE80.Windows2)_applicationObject.Windows;
int count = win.Count;
String aString = null;
for (int i = 1; i <= count; i++ )
{
aString = aString + ("The window number " + i +
" in the collection, has the caption: " + win.Item(i).Caption + "\n");
}
MessageBox.Show(aString);
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용를 참조하세요.