EventDescriptorCollection.Find(String, Boolean) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合中指定名稱的事件描述。
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 元件的類型。 它需要這個, button1 並且 textBox1 已經在表單上實例化。
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 );
}
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 不會影響桌面應用程式(通常透過雙擊圖示、輸入指令或在瀏覽器輸入網址來啟動)。 欲了解更多資訊,請參閱 HostProtectionAttribute 類別或 SQL Server 程式設計與主機保護屬性。