Hi all,

I am working in windows based application. In this application, a form contains 11 panels as 11 rows. I mean 11 panel as one by one. Each panel consits 11 checkBoxes without text only checkBoxes. if I check any one of the checkBox in any row, i need to provide a functionalites to uncheck all ohther checkBoxes if checked anyone before else the checked checkBox should be checked. if i check another one checkbox on the same row, then the previous selected checkBox should be uncheck automatically. I should not be uncheck checkbox directly. I need to achieve this by check other checkbox on the same row......

The user should not uncheck any checkboxes on the row directly. They can uncheck the checkboxes by selcecting other checkbox.

the user tries to uncheck the same checkBox dirctly by clicking on it. I need to prevent the user to uncheck the checkBox by click on the same checkbox. Instead of that the user shuld select rest of them( remainging checkBox on the same row). If the user select the second checkBox then the previus checkBox is automatically unchecked and the second checkBox is checked.

How to do that?


Recommended Answers

All 2 Replies

how are you handling your click event? I would put a clause in there to say that if it is a user generated click then check the box again esentially undoing their uncheck immediately. perhaps someone has a more elegant way of doing it.


Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click
If CheckBox1.Checked = False Then
CheckBox1.Checked = True
End If
End Sub

This might help but it will also depend on whatever else you are doing in your event handlers

hope this helps. let me know how it goes


Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Dim ctrl As Control
        Dim txt As TextBox
        Dim chkb As CheckBox

        For Each ctrl In Me.Controls
            If (ctrl.GetType() Is GetType(TextBox)) Then
                txt = CType(ctrl, TextBox)
                txt.Text = ""
            End If
            If (ctrl.GetType() Is GetType(CheckBox)) Then
                chkb = CType(ctrl, CheckBox)
                chkb.Checked = False
            End If
    End Sub


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.