我最近一直在做Sudoku任务。现在我遇到了一个小问题(是的,再次)。
我用可以填写的数字创建了按钮。现在,当我按下任何这些按钮时,我的方法应该遍历表单上的所有81个文本框,并检查它是'.Text'如果这等于按钮Tag,然后我希望文本框'forecolor被改为绿色,无论它是否被禁用。
CODE:
Public Sub udsGetal(ByVal strSenderTag As String)
For intBoxY As Integer = 0 To 2
For intCellY As Integer = 0 To 2
For intBoxX As Integer = 0 To 2
For intCellX As Integer = 0 To 2
If getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).text.Equals(strSenderTag) And getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).enabled = True Then
getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).forecolor = Color.Green
ElseIf getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).text.Equals(strSenderTag) And getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).enabled = False Then
getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).enabled = True
getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).forecolor()
getBox(intBoxX, intBoxY).getcell(intCellX, intCellY).enabled = False
End If
Next
Next
Next
Next
End Sub
可悲的是,这不起作用,我希望这是因为一个禁用的文本框,不能让它的颜色改变。 所以我的问题是:这个问题有解决方法吗?
先谢谢。
答案 0 :(得分:2)
如果你想让你的文本框“不变”"或者" uneditable"并且想要修改或更改其前景色和背景色,从不使用" enabled = false"财产,而是使用" readonly = false。"在这种情况下,您可以更改文本框的前景色和背景色。