ImageList.RecreateHandle 事件


當重新建立 Handle 時發生。Occurs when the Handle is recreated.

 event EventHandler ^ RecreateHandle;
public event EventHandler RecreateHandle;
member this.RecreateHandle : EventHandler 
Public Custom Event RecreateHandle As EventHandler 


下列程式碼範例示範如何使用這個成員。The following code example demonstrates the use of this member. 在此範例中, 事件處理常式會報告RecreateHandle事件的發生次數。In the example, an event handler reports on the occurrence of the RecreateHandle event. 此報表可協助您瞭解事件發生的時間, 並可協助您進行調試。This report helps you to learn when the event occurs and can assist you in debugging. 若要報告多個事件或經常發生的事件, 請考慮MessageBox.ShowConsole.WriteLine取代為, 或將訊息附加TextBox至多行。To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

若要執行範例程式碼, 請將它貼入包含名為ImageList ImageList1之類型實例的專案中。To run the example code, paste it into a project that contains an instance of type ImageList named ImageList1. 然後確定事件處理常式與RecreateHandle事件相關聯。Then ensure that the event handler is associated with the RecreateHandle event.

private void ImageList1_RecreateHandle(Object sender, EventArgs e) {

   MessageBox.Show("You are in the ImageList.RecreateHandle event.");

Private Sub ImageList1_RecreateHandle(sender as Object, e as EventArgs) _ 
     Handles ImageList1.RecreateHandle

   MessageBox.Show("You are in the ImageList.RecreateHandle event.")

End Sub


當您透過Handle ColorDepth變更或ImageSize之類的動作重新建立時, 您可以使用這個事件來執行特殊處理。You can use this event to do special processing when the Handle is recreated by actions such as changing the ColorDepth or ImageSize. 可能需要特殊處理, 因為在設定ColorDepth Images屬性之後ImageSize設定或屬性會導致重新建立控制碼, 並捨棄影像。Special processing may be required because setting the ColorDepth or the ImageSize property after setting the Images property causes the handle to be recreated and the images to be discarded.