关于使用参数传递给复选框的的CheckedChanged事件复选框、参数、事件、CheckedChanged

2023-09-07 00:18:25 作者:南风如我意

如何显示文字复选框的属性值被点击时?

How do I display the value of the "Text" property of a checkbox when it is clicked?

于是用的CheckedChanged事件,类型发送方放两个参数; EventArgs的传递。

So with the CheckedChanged event, two arguments of type sender & eventArgs are passed.

如何使用这些参数做我一样的吗?

How do I the same using these arguments?

推荐答案

是的,但你也可能要取消它,如果它未选中?

Yes, but do you possibly also want to unset it if it's unchecked?

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    If CType(sender, CheckBox).Checked Then
        Label1.Text = CType(sender, CheckBox).Text
    Else
        Label1.Text = ""
    End If
End Sub