VB.NET 学习---(5)
发布时间:2020-12-16 23:33:49 所属栏目:大数据 来源:网络整理
导读:下面的代码示例是一个事件处理程序,该处理程序在 Text 属性值更改时执行。 Control 类有几个名称模式为 PropertyName Changed 的方法,它们在相应的 PropertyName 值( PropertyName 表示相应的属性名)更改时引发。 Private Sub currencyTextBox_TextChang
下面的代码示例是一个事件处理程序,该处理程序在 Text 属性值更改时执行。 Control 类有几个名称模式为PropertyNameChanged的方法,它们在相应的PropertyName值(PropertyName表示相应的属性名)更改时引发。 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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |