Click here to Skip to main content
15,171,576 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I am at present developing a windows application in vb .Net 3.5 . In my application I have generated few radio buttons which generates automatically in a group box while loading. If we click any of those dynamically generated radio buttons in another group box another set of check box gets generated dynamically.

Now I select a radio button and few check boxes are generated and then i tick few check boxes in it. Then i am changing the radio button now i want to clear the check boxes that I have ticked in previous radio button selection now the radio button i select is different so the check box should be cleared.

P.S For all dynamically generated radio buttons check boxes generated are same. Just need to clear the check box selection when radio button selection differs.

My problem is first time the check box is cleared but next time it is not getting cleared.

Click event for dynamically generated Radio Buttons:

VB
AddHandler myradiobutton(i).Click, AddressOf BtnExitOnClick


Definition in BtnExitOnClick :

VB
Public Sub BtnExitOnClick(ByVal sender As Object, ByVal e As EventArgs)
       Dim str9 As String = "Select Addon from facilities"
       Dim ds9 As New DataSet
       Dim ii As Integer
       ds9 = connobj.Dsselectquery(str9)
       For ii = 0 To ds9.Tables(0).Rows.Count - 1
           Try
               If mycheckbox(ii).Name = "NewCHK" & ii Then
                   mycheckbox(ii).CheckState = CheckState.Unchecked
               End If
           Catch ex As Exception

           End Try
       Next


This is how the check box is created dynamically:

VB
 For i = 0 To ds1.Tables(0).Rows.Count - 1

mycheckbox(i).Name = "NewCHK" & i



While changing the radio Button selection for the first time the check box checked state is set back to unchecked state. But when i do that many times it doesn't happen.

How to clear the dynamically generated check box states from checked to unchecked . More resources working with dynamic check box and radio buttons will be more helpful. Thanks!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900