我正试图找到一种默认禁用单选按钮的方法。我已设法在CheckedChanged
的事件处理程序中禁用它们,但这仅在用户采取操作时才有效。如何在默认情况下禁用控件?
Private Sub rdoCustomer_CheckedChanged(ByVal sender As Object,
ByVal e As EventArgs) _
Handles rdoCustomer.CheckChanged, rdoDepartment.CheckedChanged
rdoCustomer.Enabled = False
rdoCustomer.Checked = True
rdoDepartment.Enabled = False
End Sub
答案 0 :(得分:2)
要“默认”设置任何内容,只需将其写入Form Load Event
即可。样品:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
rdoCustomer.Enabled = False
rdoCustomer.Checked = False
rdoDepartment.Enabled = False
rdoDepartment.Checked = False
End Sub
或者,也可以通过“设计视图”中给定控件的属性。所有这一切都假设控件不是在运行时创建的(在这种情况下,就在创建之后)。