请问VB.NET里面改textbox文字颜色(forecolor)和背景颜色(backcolor)怎么弄?有具体的题目!!
题目的要求是用checkbox,一个让字变成红色,一个让背景颜色变成黄的,我的这个代码写出来,只有两个一起选了,字和背景颜色才会变,并且还不能还原。请高手指点呀~~~~...
题目的要求是用checkbox,一个让字变成红色,一个让背景颜色变成黄的,我的这个代码写出来,只有两个一起选了,字和背景颜色才会变,并且还不能还原。请高手指点呀~~~~
展开
3个回答
展开全部
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox1.ForeColor = Color.Red
Else
TextBox1.ForeColor = Color.Black
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox1.BackColor = Color.Yellow
Else
TextBox1.BackColor = Color.White
End If
End Sub
If CheckBox1.Checked = True Then
TextBox1.ForeColor = Color.Red
Else
TextBox1.ForeColor = Color.Black
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox1.BackColor = Color.Yellow
Else
TextBox1.BackColor = Color.White
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询