EventDescriptorCollection.Find(String, Boolean) メソッド

定義

コレクション内の指定した名前を持つイベントの説明を取得します。

public:
 virtual System::ComponentModel::EventDescriptor ^ Find(System::String ^ name, bool ignoreCase);
public virtual System.ComponentModel.EventDescriptor Find (string name, bool ignoreCase);
public virtual System.ComponentModel.EventDescriptor? Find (string name, bool ignoreCase);
abstract member Find : string * bool -> System.ComponentModel.EventDescriptor
override this.Find : string * bool -> System.ComponentModel.EventDescriptor
Public Overridable Function Find (name As String, ignoreCase As Boolean) As EventDescriptor

パラメーター

name
String

コレクションから取得するイベントの名前。

ignoreCase
Boolean

イベントの大文字と小文字を区別しない場合は true。それ以外の場合は false

戻り値

指定した名前の EventDescriptor。イベントが存在しない場合は null

次のコード例では、特定 EventDescriptorの を検索します。 この EventDescriptor コンポーネントの種類をテキスト ボックスに出力します。 フォームで と textBox1button1インスタンス化されている必要があります。

private:
   void FindEvent()
   {
      // 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->Find( "Resize", false );
      
      // Prints the event name and event description.
      textBox1->Text = String::Concat( myEvent->Name, ": ", myEvent->Description );
   }
private void FindEvent() {
    // 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.Find("Resize", false);
 
    // Prints the event name and event description.
    textBox1.Text = myEvent.Name + ": " + myEvent.Description;
 }
Private Sub FindEvent()
    ' 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.Find("Resize", False)
    
    ' Prints the event name and event description.
    textBox1.Text = myEvent.Name & ": " & myEvent.Description
End Sub

注釈

注意

HostProtectionAttributeこのクラスに適用される属性のプロパティ値は Resources です。 Synchronization HostProtectionAttribute は、デスクトップ アプリケーション (通常、アイコンのダブルクリック、コマンドの入力、またはブラウザーへの URL の入力により起動されます) には影響しません。 詳細については、 クラスまたは SQL Server プログラミング属性とホスト保護属性に関するページを参照してくださいHostProtectionAttribute

適用対象

こちらもご覧ください