Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试根据 TextBox 中显示的文本在运行时设置 System.Windows.Forms.TextBox 的 ForeColor 属性,但我所做的任何事情都不会覆盖 Visual Studio 设置的属性值。
我正在使用 VB Express 2010。
您可以处理 Textbox.TextChanged 事件,如下所示:
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged If TextBox1.Text.Length Mod 2 = 0 Then TextBox1.ForeColor = Color.Red Else TextBox1.ForeColor = Color.Blue End If End Sub