Freigeben über


Control.RightToLeftChanged-Ereignis

Tritt ein, wenn sich der RightToLeft-Eigenschaftenwert ändert.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Event RightToLeftChanged As EventHandler
'Usage
Dim instance As Control
Dim handler As EventHandler

AddHandler instance.RightToLeftChanged, handler
public event EventHandler RightToLeftChanged
public:
event EventHandler^ RightToLeftChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_RightToLeftChanged (EventHandler value)

/** @event */
public void remove_RightToLeftChanged (EventHandler value)
JScript unterstützt die Verwendung von Ereignissen, aber nicht die Deklaration von neuen Ereignissen.

Hinweise

Dieses Ereignis wird ausgelöst, wenn die RightToLeft-Eigenschaft durch programmgesteuerte Änderungen oder Benutzerinteraktionen geändert wird.

Weitere Informationen zum Behandeln von Ereignissen finden Sie unter Behandeln von Ereignissen.

Beispiel

Im folgenden Codebeispiel wird ein Ereignishandler veranschaulicht, der beim Ändern des Text-Eigenschaftenwerts ausgeführt wird. Die Control-Klasse verfügt über mehrere Methoden mit dem Namensmuster PropertyNameChanged, die ausgelöst werden, wenn sich der entsprechende PropertyName-Wert ändert (PropertyName stellt den Namen der entsprechenden Eigenschaft dar).

Im folgenden Codebeispiel wird die ForeColor einer TextBox geändert, die Währungsdaten anzeigt. Im Beispiel wird der Text in eine Dezimalzahl umgewandelt und die ForeColor in Color.Red geändert, wenn die Zahl negativ ist, und in Color.Black, wenn die Zahl positiv ist. Für dieses Beispiel müssen Sie über ein Form verfügen, das eine TextBox enthält.

Private Sub currencyTextBox_TextChanged(sender As Object, _ 
  e As EventArgs) Handles currencyTextBox.TextChanged
   Try
      ' Convert the text to a Double and determine if it is a negative number.
      If Double.Parse(currencyTextBox.Text) < 0 Then
         ' If the number is negative, display it in Red.
         currencyTextBox.ForeColor = Color.Red
      Else
         ' If the number is not negative, display it in Black.
         currencyTextBox.ForeColor = Color.Black
      End If
   Catch
      ' If there is an error, display the text using the system colors.
      currencyTextBox.ForeColor = SystemColors.ControlText
   End Try
End Sub 
private void currencyTextBox_TextChanged(object sender, EventArgs e)
{
   try
   {
      // Convert the text to a Double and determine if it is a negative number.
      if(double.Parse(currencyTextBox.Text) < 0)
      {
         // If the number is negative, display it in Red.
         currencyTextBox.ForeColor = Color.Red;
      }
      else
      {
         // If the number is not negative, display it in Black.
         currencyTextBox.ForeColor = Color.Black;
      }
   }
   catch
   {
      // If there is an error, display the text using the system colors.
      currencyTextBox.ForeColor = SystemColors.ControlText;
   }
}
private:
   void currencyTextBox_TextChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         // Convert the text to a Double and determine if it is a negative number.
         if ( Double::Parse( currencyTextBox->Text ) < 0 )
         {
            // If the number is negative, display it in Red.
            currencyTextBox->ForeColor = Color::Red;
         }
         else
         {
            // If the number is not negative, display it in Black.
            currencyTextBox->ForeColor = Color::Black;
         }
      }
      catch ( Exception^ ) 
      {
         // If there is an error, display the text using the system colors.
         currencyTextBox->ForeColor = SystemColors::ControlText;
      }
   }
private void currencyTextBox_TextChanged(Object sender, EventArgs e)
{
    try {
        // Convert the text to a Double and determine if it is a 
        // negative number.
        if (System.Double.Parse(currencyTextBox.get_Text()) < 0) {
            // If the number is negative, display it in Red.
            currencyTextBox.set_ForeColor(Color.get_Red());
        }
        else {
            // If the number is not negative, display it in Black.
            currencyTextBox.set_ForeColor(Color.get_Black());
        }
    }
    catch (System.Exception exp) {
        // If there is an error, display the text using the system colors.
        currencyTextBox.set_ForeColor(SystemColors.get_ControlText());
    }
} //currencyTextBox_TextChanged

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Windows.Forms-Namespace
OnRightToLeftChanged
Control.RightToLeft-Eigenschaft