Control.RightToLeftChanged 事件

定义

RightToLeft 属性值更改时发生。

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

事件类型

示例

下面的代码示例是属性值更改时 Text 执行的事件处理程序。 类Control具有多个名称模式 PropertyName 的方法,这些方法在相应的 PropertyNameChanged 值更改时引发 (PropertyName 表示) 相应属性的名称。

下面的代码示例更改ForeColorTextBox显示货币数据的 。 该示例将文本转换为十进制数,如果数字为负数,则将 更改为 ForeColorColor.Red ;如果该数字为正数,则更改为 Color.Black 。 此示例要求具有 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

另请参阅