checkbox 和 text 文本框连接——学生管理系统之用户体验

来源:互联网 发布:生活常识问答软件 编辑:程序博客网 时间:2024/06/03 11:06

目的:实现勾选checkbox后,对应的text文本框可以输入,未选中不可输入。


第一步:创建Checkbox的数组,减少多次添加重复代码的麻烦。采用复制粘贴即可。并把text的enable属性设置为false

第二步:点击check进入check click事件

Dim S As Integer

    S = Check1(0).Index

    If Check1(S).Value = 0 Then

    txtSID.Enabled = False

    Else: Check1(S).Value = 1

    txtSID.Enabled = True

    End If

    S = Check1(2).Index

    If Check1(S).Value = 0 Then

    txtName.Enabled = False

    Else: Check1(S).Value = 1

    txtName.Enabled = True

    End If

    S = Check1(1).Index

    If Check1(S).Value = 0 Then

    txtClassNo.Enabled = False

    Else: Check1(S).Value = 1

    txtClassNo.Enabled = True

    End If

第三步:如果查询完一次后,查询成功后,应该自动清除之前查询的信息,这是小的细节。

  txtSID.Text = ""
  txtName.Text = ""
  txtCourse.Text = ""

原创粉丝点击