TabControlCancelEventArgs.TabPageIndex Właściwość

Definicja

Pobiera zerowy indeks TabPage w kolekcji TabPages .

public:
 property int TabPageIndex { int get(); };
public int TabPageIndex { get; }
member this.TabPageIndex : int
Public ReadOnly Property TabPageIndex As Integer

Wartość właściwości

Indeks oparty na zerowej TabPage wartości w kolekcji TabPages .

Przykłady

Poniższy przykład kodu przedstawia użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie zdarzenia TabControl.Selecting . Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub zdarzeń, które występują często, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączeniem go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu TabControl o nazwie TabControl1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem TabControl.Selecting .

private void TabControl1_Selecting(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(), "Selecting Event" );
}
Private Sub TabControl1_Selecting(sender as Object, e as TabControlCancelEventArgs) _ 
     Handles TabControl1.Selecting

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "TabPage", e.TabPage)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "TabPageIndex", e.TabPageIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Action", e.Action)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Selecting Event")

End Sub

Dotyczy

Zobacz też