Cet article a fait l’objet d’une traduction automatique. Pour afficher l’article en anglais, activez la case d’option Anglais. Vous pouvez également afficher le texte anglais dans une fenêtre contextuelle en faisant glisser le pointeur de la souris sur le texte traduit.
Traduction
Anglais

TabControl.Deselecting événement

 

Date de publication : novembre 2016

Se produit avant qu'un onglet soit désélectionné, en activant un gestionnaire pour annuler la modification de l'onglet.

Espace de noms:   System.Windows.Forms
Assembly:  System.Windows.Forms (dans System.Windows.Forms.dll)

public event TabControlCancelEventHandler Deselecting

When the current tab changes in a T:System.Windows.Forms.TabControl, the following events occur in the following order.

These events let you perform tasks such as canceling a tab change if a T:System.Windows.Forms.TabPage is in an invalid state or updating the state of a newly displayed T:System.Windows.Forms.TabPage.

The current tab changes when the user clicks a tab, when you call the Overload:System.Windows.Forms.TabControl.DeselectTab or Overload:System.Windows.Forms.TabControl.SelectTab method, or when you change the value of the P:System.Windows.Forms.TabControl.SelectedIndex or P:System.Windows.Forms.TabControl.SelectedTab property.

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the E:System.Windows.Forms.TabControl.Deselecting event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing Overload:System.Windows.Forms.MessageBox.Show with Overload:System.Console.WriteLine or appending the message to a multiline T:System.Windows.Forms.TextBox.

To run the example code, paste it into a project that contains an instance of type T:System.Windows.Forms.TabControl named TabControl1. Then ensure that the event handler is associated with the E:System.Windows.Forms.TabControl.Deselecting event.

private void TabControl1_Deselecting(Object sender, TabControlCancelEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "TabPage", e.TabPage );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "TabPageIndex", e.TabPageIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Deselecting Event" );
}

.NET Framework
Disponible depuis 2.0
Retour au début
Afficher: