Select Checkbox

6 posts, 0 answers
  1. Manikandan
    Manikandan avatar
    13 posts
    Member since:
    Apr 2009

    Posted 26 Jun 2009 Link to this post

    How to selece checkbox in the current row on cell click?
  2. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 26 Jun 2009 Link to this post

    Hello,

    Try the following:


    In the cellclick event of the radgrid add this line of code.

    where in "Cells" the column index number is of your checkbox
     
    private void radgrid_CellClick(object sender, GridViewCellEventArgs e) 
      radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = true
    }
  3. UI for WinForms is Visual Studio 2017 Ready
  4. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 26 Jun 2009 Link to this post

    An update:

    If you want that when a second time the cell is clicked it unselects it add this:

    private void radgrid_CellClick(object sender, GridViewCellEventArgs e) 
      if (!(bool)radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value) 
      { 
        radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = true
      }else 
      { 
        radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = false
      }             



  5. Manikandan
    Manikandan avatar
    13 posts
    Member since:
    Apr 2009

    Posted 27 Jun 2009 Link to this post

    I had made my checkbox column alone radgrid.readonly=False and for all other columns radgrid.readonly=true. After doing this the cell click event doesn't fire when i click on the other columns. I doesnt want the user to edit the data.So i had made my radgrid.readonly=true. So that i cant do that in the cell click event .
  6. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 29 Jun 2009 Link to this post

    Hi,

    I looked at my code and I have the same situation as you.
    My grid has the property AllowEditRow = false under MasterGridViewTemplate.
    In my code for adding the columns I have the checkbox row property ReadOnly = false. But my other column don't have the property ReadOnly = true.

    Even so it isn't possible to edit the rows. even with the keystroke F2.

    If this doesn't do the trick post some sample code of you project.


  7. Developer
    Developer avatar
    16 posts
    Member since:
    Jun 2009

    Posted 23 Apr 2010 Link to this post

    Ok this is a very old thread, but an even smaller approach would be:

     Private Sub GridView1_CellClick(ByVal sender As ObjectByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles GridView1.CellClick 
            ToggleRowSelect(sender, e) 
     
    Try 
    ' Assuming first cell is of CheckBoxColumn 
     
                Dim flag As Boolean = DirectCast(GridView1.MasterGridViewTemplate.Rows(e.RowIndex).Cells(0).Value, Boolean
                GridView1.MasterGridViewTemplate.Rows(e.RowIndex).Cells(0).Value = Not flag 
            Catch ex As Exception 
    MessageBox.Show(ex.Message) 
            End Try 
     
        End Sub 


Back to Top
UI for WinForms is Visual Studio 2017 Ready