需要帮助复选框列表 [英] need help for checkboxlist

查看:48
本文介绍了需要帮助复选框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有一个复选框列表。我需要当我选择一个复选框,然后所有其他复选框都是readonly属性。它的意思是。一次只能选中一个复选框。直到我不刷新我的页面。我怎么能这样做。

解决方案

单选按钮有办法实现这个结果,但你仍然想要这样做,然后处理CheckBox.CheckedChanged事件所有四个复选框的相同子



 私人  Sub  CheckBox1_CheckedChanged(sender  As  System。 Object ,e  As  System.EventArgs)_ 
句柄 CheckBox1.CheckedChanged,CheckBox2.CheckedChanged,CheckBox3.CheckedChanged,CheckBox4。 CheckedChanged
' cast cast
Dim senderCheck As CheckBox = DirectCast (发件人,CheckBox)

' 遍历所有复选框
对于 每个复选框 {CheckBox1,CheckBox2,CheckBox3,CheckBox4}

' < span class =code-comment>仅对非发件人框应用更改
如果复选框 IsNot senderCheck 然后

' 将属性设置为发件人的对面,以便您可以在未选中时重新设置
checkbox.Enabled = senderCheck.Checked
结束 如果
下一步
结束 Sub


sir, i have a checkboxlist. i need that when i select one checkbox then all other checkbox are readonly property. it means. only one checkbox is selected at one time. untill i am not refresh my page. how can i do it.

解决方案

Radio buttons has the way to achieve this result, but you still wanted to do this then, Handle the CheckBox.CheckedChanged event with the same sub for all four checkboxes

Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) _
    Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged
    'cast sender
    Dim senderCheck As CheckBox = DirectCast(sender, CheckBox)

    'loop through all checkboxes
    For Each checkbox In {CheckBox1, CheckBox2, CheckBox3, CheckBox4}

        'only apply changes to non-sender  boxes
        If checkbox IsNot senderCheck Then

            'set property to opposite of sender so you can renable when unchecked
            checkbox.Enabled = Not senderCheck.Checked
        End If
    Next
End Sub


这篇关于需要帮助复选框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆