EventDescriptorCollection.Item[] 속성

정의

지정된 이벤트를 가져옵니다.

오버로드

Item[Int32]

지정된 인덱스 번호를 갖는 이벤트를 가져오거나 설정합니다.

Item[String]

지정된 이름의 이벤트를 가져오거나 설정합니다.

Item[Int32]

Source:
EventDescriptorCollection.cs
Source:
EventDescriptorCollection.cs
Source:
EventDescriptorCollection.cs

지정된 인덱스 번호를 갖는 이벤트를 가져오거나 설정합니다.

public:
 virtual property System::ComponentModel::EventDescriptor ^ default[int] { System::ComponentModel::EventDescriptor ^ get(int index); };
public virtual System.ComponentModel.EventDescriptor this[int index] { get; }
public virtual System.ComponentModel.EventDescriptor? this[int index] { get; }
member this.Item(int) : System.ComponentModel.EventDescriptor
Default Public Overridable ReadOnly Property Item(index As Integer) As EventDescriptor

매개 변수

index
Int32

가져오거나 설정할 EventDescriptor의 인덱스(0부터 시작) 번호입니다.

속성 값

지정된 인덱스 번호가 있는 EventDescriptor입니다.

예외

indexItem[Int32]에 대해 유효한 인덱스가 아닌 경우

예제

다음 코드 예제에서는 합니다 Item[] 속성의 이름을 출력 하는 EventDescriptor 텍스트 상자에 인덱스 번호로 지정 된 합니다. 인덱스 번호는 0부터 시작하므로 이 예제에서는 두 번째 EventDescriptor의 이름을 인쇄합니다. 및 가 button1textBox1 양식에서 인스턴스화되어야 합니다.

private:
   void PrintIndexItem()
   {
      
      // Creates a new collection and assigns it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Prints the second event's name.
      textBox1->Text = events[ 1 ]->ToString();
   }
private void PrintIndexItem() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Prints the second event's name.
    textBox1.Text = events[1].ToString();
 }
Private Sub PrintIndexItem()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Prints the second event's name.
    textBox1.Text = events(1).ToString()
End Sub

설명

인덱스 번호는 0부터 시작 합니다. 따라서 특정 숫자 위치에서 1 빼야 EventDescriptor 에 액세스 하려면 해당 EventDescriptor합니다. 예를 들어, 세 번째 가져오려는 EventDescriptor를 지정 해야 myColl[2]합니다.

추가 정보

적용 대상

Item[String]

Source:
EventDescriptorCollection.cs
Source:
EventDescriptorCollection.cs
Source:
EventDescriptorCollection.cs

지정된 이름의 이벤트를 가져오거나 설정합니다.

public:
 virtual property System::ComponentModel::EventDescriptor ^ default[System::String ^] { System::ComponentModel::EventDescriptor ^ get(System::String ^ name); };
public virtual System.ComponentModel.EventDescriptor this[string name] { get; }
member this.Item(string) : System.ComponentModel.EventDescriptor
Default Public Overridable ReadOnly Property Item(name As String) As EventDescriptor

매개 변수

name
String

가져오거나 설정할 EventDescriptor의 이름입니다.

속성 값

지정된 이름의 EventDescriptor이거나, 해당 이벤트가 없을 경우 null입니다.

예제

다음 코드 예제를 사용 합니다 Item[] 속성을 인덱스에서 지정 된 에 대 한 EventDescriptor 구성 요소의 형식을 인쇄 합니다. 및 가 button1textBox1 양식에서 인스턴스화되어야 합니다.

private:
   void PrintIndexItem2()
   {
      
      // Creates a new collection and assigns it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Sets an EventDescriptor to the specific event.
      EventDescriptor^ myEvent = events[ "KeyDown" ];
      
      // Prints the name of the event.
      textBox1->Text = myEvent->Name;
   }
private void PrintIndexItem2() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Sets an EventDescriptor to the specific event.
    EventDescriptor myEvent = events["KeyDown"];
 
    // Prints the name of the event.
    textBox1.Text = myEvent.Name;
 }
Private Sub PrintIndexItem2()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Sets an EventDescriptor to the specific event.
    Dim myEvent As EventDescriptor = events("KeyDown")
    
    ' Prints the name of the event.
    textBox1.Text = myEvent.Name
End Sub

설명

속성은 Item[] 이름을 검색할 때 대/소문자를 구분합니다. 즉, "Ename"과 "ename"이라는 이름은 두 가지 이벤트로 간주됩니다.

참고

합니다 HostProtectionAttribute 이 클래스에 적용 된 특성에는 다음과 같은 Resources 속성 값: Synchronization합니다. HostProtectionAttribute는 대개 아이콘을 두 번 클릭하거나, 명령을 입력하거나, 브라우저에서 URL을 입력하여 시작되는 데스크톱 애플리케이션에 영향을 미치지 않습니다. 자세한 내용은 참조는 HostProtectionAttribute 클래스 또는 SQL Server 프로그래밍 및 호스트 보호 특성합니다.

추가 정보

적용 대상