CheckBox column

Posted by: hpadmasola1 on 8 September 2017, 2:07 pm EST

  • Posted 8 September 2017, 2:07 pm EST

    <P>Hi, </P>
    <P>Iam loading my grid where the first column is a checkbox. By default, I have all the checkboxes in the Grid as checked when I load my grid.</P>
    <P>I want to have a button on my page when clicked it should make all checkboxes unchecked. And when I click it again, it should check them all.</P>
    <P>I tried using the following code in the button click event but it didnt work properly.</P>
    <P>If BtnCheckall.Text = "UnCheck All" Then<BR>            FPspread1.ActiveSheet.Columns(0).DataField = 0<BR>            BtnCheckall.Text = "Check All"<BR>Else<BR>            FPspread1.ActiveSheet.Columns(0).DataField = 1<BR>            BtnCheckall.Text = "UnCheck All"<BR>End If</P>
    <P>Any help is appreciated.</P>
    <P>Harish</P>
  • Replied 8 September 2017, 2:07 pm EST

    <p>Hello Harish, </p><p>If you have a Column as CheckBoxCellType and you want to select/unselect all the CheckBoxes at once you may loop through the Cells and set their corresponding value to 1 for True(Checked) and 0 for False(Unchecked).Please have a look at the following code snippet where Column(2) is a CheckBoxCellType and we are using a ButtonClick Event to Check/Uncheck the Check Boxes,</p><p> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br>        If Me.Button1.Text = "Check All" Then<br>            For i As Integer = 0 To FpSpread1.ActiveSheet.RowCount - 1<br>                FpSpread1.ActiveSheet.Cells(i, 2).Value = 1<br>            Next<br>            Me.Button1.Text = "UnCheck All"<br><br>        Else : Me.Button1.Text = "UnCheck All"<br>            For i As Integer = 0 To FpSpread1.ActiveSheet.RowCount - 1<br>                FpSpread1.ActiveSheet.Cells(i, 2).Value = 0<br>            Next<br>            Me.Button1.Text = "Check All"<br>        End If<br>    End Sub </p><p>I hope it will help you.</p><p>Thanks,</p><p> </p>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels