我需要一些帮助,在禁用它后将框架的标签颜色变为灰色。启用和禁用框架非常简单,但我在如何使所有标签属于该框架并将颜色更改为灰色方面进行了分散。我试图用它们各自的标签标记所有框架文本框,并在文本框级别上工作,但它只是不起作用。这是我的代码:
Private Sub cbxCSENetworkDeseign_Click()
Dim Tbox As MSForms.TextBox
If cbxCSENetworkDeseign.Value = True Then 'Check box that will disable / enable the frame
frmCustomerDetails.Enabled = False
For Each Tbox In frmCustomerDetails.Controls
Controls(Tbox.Tag).ForeColor = vbGrayText
Next Tbox
Else
frmCustomerDetails.Enabled = True
For Each Tbox In frmCustomerDetails.Controls
Controls(Tbox.Tag).ForeColor = vbBlack
Next Tbox
End If
End Sub
答案 0 :(得分:0)
试试这个:
Private Sub cbxCSENetworkDeseign_Click()
Dim Tbox As Object 'MSForms.TextBox
If cbxCSENetworkDeseign.Value = True Then 'Check box that will disable / enable the frame
frmCustomerDetails.Enabled = False
For Each Tbox In frmCustomerDetails.Controls
Tbox.ForeColor = vbGrayText
Next Tbox
Else
frmCustomerDetails.Enabled = True
For Each Tbox In frmCustomerDetails.Controls
Tbox.ForeColor = vbBlack
Next Tbox
End If
End Sub
答案 1 :(得分:0)
@Excel Hero 谢谢Bud。 但是在重新检查我的代码之后,我发现缺少的是完成我框架中的所有标签(其中一些是空的),所以当我运行它时它实际上正在工作。 thx再次萌芽 ;)