Click here to Skip to main content
15,916,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 4 checkboxes and 1 textbox on a web-form. If I type 1,2 in the textbox, then checkbox1 and checkbox2 will be checked. The code for this is as below. But I want when I type 1,2 then checkbox1 and checkbox2 should be disabled and unchecked.

Can anybody update this code?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim separator As Char = ","c
        Dim allIIDs As New List(Of Int32)
        If TextBox1.Text.Length <> 0 Then
            For Each strNum As String In TextBox1.Text.Split(separator)
                Dim num As Int32
                If Int32.TryParse(strNum, num) Then
                    allIIDs.Add(num)
                End If
            Next
        End If
        allIIDs.Sort()
        For Each control As Control In Panel1.Controls
            If TypeOf control Is CheckBox Then
                Dim chk As CheckBox = DirectCast(control, CheckBox)
                chk.Checked = allIIDs.BinarySearch(Int32.Parse(chk.Text)) > -1
            End If
        Next
    End Sub


[edit]Code block added to improve legibility - OriginalGriff[/edit]
Posted
Updated 14-Nov-10 5:12am
v2

1 solution

THe above code will check the checkbox1 and checkbox2 when i type 1,2 in textbox....


But i want when i type1,2 in textbox then checkbox1 and checkbox2 will be unchecked and disabled also ... !!


can any body edit my code above to do that ?
 
Share this answer
 

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