Control.RightToLeftChanged 事件

定義

發生在 RightToLeft 屬性值變更時。

C#
public event EventHandler RightToLeftChanged;
C#
public event EventHandler? RightToLeftChanged;

事件類型

範例

下列程式碼範例是屬性值變更時 Text 所執行的事件處理常式。 類別 Control 有數個名稱模式PropertyNameChanged 的方法,當對應的PropertyName值變更 (PropertyName代表對應屬性的名稱) 時引發。

下列程式碼範例會變更 ForeColorTextBox 顯示貨幣資料的 。 本範例會將文字轉換成十進位數,如果數位為負數,則變更為 ,如果 Color.Black 數位為正數,則為 。 ForeColorColor.Red 此範例需要您有 Form 包含 的 TextBox

C#
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;
   }
}

備註

如果屬性是透過程式設計修改或使用者互動來變更,就會 RightToLeft 引發這個事件。

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱