ProgressChangedEventArgs.UserState Właściwość

Definicja

Pobiera unikatowy stan użytkownika.

public:
 property System::Object ^ UserState { System::Object ^ get(); };
public object UserState { get; }
public object? UserState { get; }
member this.UserState : obj
Public ReadOnly Property UserState As Object

Wartość właściwości

Unikatowy Object wskazujący stan użytkownika.

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 PictureBox.LoadProgressChanged . 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 PictureBox o nazwie PictureBox1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem PictureBox.LoadProgressChanged .

private void PictureBox1_LoadProgressChanged(Object sender, ProgressChangedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ProgressPercentage", e.ProgressPercentage );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "UserState", e.UserState );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "LoadProgressChanged Event" );
}
Private Sub PictureBox1_LoadProgressChanged(sender as Object, e as ProgressChangedEventArgs) _ 
     Handles PictureBox1.LoadProgressChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ProgressPercentage", e.ProgressPercentage)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "UserState", e.UserState)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"LoadProgressChanged Event")

End Sub

Dotyczy

Zobacz też