老师好,
请教一下,希望在选择不同的表行后,根据表行的内容,对窗口按钮的背景色进行赋值,现在只有第一次选择行后有效果,重新选择不同行后,没效果,请教一下,代码要怎么改,谢谢!
For Each dr1 As DataRow In DataTables("表B").DataRows
If dr1("第二列") = "进行中" Then
Forms("窗口1").Controls("Button2").BackColor = Color.blue
Forms("窗口1").Controls("Button1").BackColor = Color.blue
ElseIf dr1("第二列") = "异常" Then
Forms("窗口1").Controls("Button2").BackColor = Color.red
Forms("窗口1").Controls("Button1").BackColor = Color.red
ElseIf dr1("第二列") = "完成" Then
Forms("窗口1").Controls("Button2").BackColor = Color.Green
Forms("窗口1").Controls("Button1").BackColor = Color.Green
ElseIf dr1("第二列") = "暂停" Then
Forms("窗口1").Controls("Button2").BackColor = Color.Yellow
Forms("窗口1").Controls("Button1").BackColor = Color.Yellow
Else
If dr1("第二列") = "待开始" Then
Forms("窗口1").Controls("Button2").BackColor = Color.Silver
Forms("窗口1").Controls("Button1").BackColor = Color.Silver
End If
End If
Next
谢谢!