GridViewCheckBoxColumn - check value while iterating through grid rows

3 posts, 0 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    65 posts
    Member since:
    May 2016

    Posted 16 Nov 2018 Link to this post

    I need to iterate through the grid's rows and determine the boolean value for the checkbox column. This operation occurs when the user clicks on a button outside of the grid.

     

    My attempts thus far have not returned 'true' on any rows that have the checkbox checked.

     

    1.For x As Integer = 0 To dgvMain.RowCount - 1
    2.     
    3.    If DirectCast((dgvMain.Rows(x).Cells("colTag")).ColumnInfo, Telerik.WinControls.UI.GridViewCheckBoxColumn).Checked = True Then
    4.        _mvTaggedItems &= dgvMain.Rows(x).Cells("colItem").Value & DataBASIC.VM
    5.    End If
    6.Next
  2. Gone2TheDogs
    Gone2TheDogs avatar
    65 posts
    Member since:
    May 2016

    Posted 16 Nov 2018 in reply to Gone2TheDogs Link to this post

    After improving my query, I found a good example. Line 06 is what I used, which works. There is probably a more efficient answer.

    01.Private Sub BuildRecord()
                                 
    03.    Try
    04.        For x As Integer = 0 To dgvMain.RowCount - 1
    05.            Dim bTagged As Boolean = False
    06.            Boolean.TryParse(dgvMain.Rows(x).Cells("colTag").Value, bTagged)
    07.            If bTagged Then
    08.                _mvTaggedItems &= dgvMain.Rows(x).Cells("colItem").Value & DataBASIC.VM
    09.            End If
    10.        Next
    11.        If Strings.Right(_mvTaggedItems, 1) = DataBASIC.VM Then
    12.            _mvTaggedItems = Strings.Left(_mvTaggedItems, _mvTaggedItems.Length - 1)
    13.        End If
    14.    Catch ex As Exception
    15.        ShowErrorBox(ex.Message)
    16.        _error = True
    17.        Exit Sub
    18.    End Try
    19. 
    20.End Sub
  3. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 19 Nov 2018 Link to this post

    Hello Bob,

    I am glad that you have found a solution to this. Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top