Forum Discussion

mandalsasmita88's avatar
mandalsasmita88
New Contributor
12 years ago

How to ckick on the Checkbox of a grid.

Hi ,

i am trying to click on the checkbox which is present inside the gridview.

But i am not finding any property value.By using "obj.item(0, 1).click" also it is not working.



Can any body solve this issue.

Thanks in advance.

5 Replies

  • Here is the way I'm manipulating it, let me know if it's helpful for you.




    Sub ClickCheckboxGridColumn(objGrid, i, strValue) 


      Dim strCurCellValue 


      SetFocusGridCell objGrid, 0, i


      'get the current cell value 


      strCurCellValue = objGrid.Views(0).Columns(i).EditValue 


      If UCase(Trim(strCurCellValue)) <> UCase(Trim(strValue)) Then


        objGrid.Keys " " 


      End If 


    End Sub 


     


    Function SetFocusGridCell(objGrid, viewIndex, colIndex) 


      Dim blnResult 


      blnResult = False


      If Not IsNull (objGrid) and objGrid.Exists and viewIndex >= 0 and colIndex >= 0 Then 


        If Not objGrid.Views(viewIndex).Columns(colIndex).Focused Then 


          objGrid.Views(viewIndex).Columns(colIndex).Focused = True 


          blnResult = True 


        End If 


      End If 


      SetFocusGridCell = blnResult 


    End Function 


    'code snippet to find a column index by column title "Department", I'm using View 0 


    Dim colIndex 


    Dim objGridView0 


    Set objGridView0 = objGrid.Views(0)


    colIndex = -1


    For index = 0 to objGridView0.ColumnCount-1 


      Select Case objGridView0.Columns(index).Caption 


        Case "Department" colIndex = index 


        Exit For


      End Select


    Next 


     


    'calls the function on objGrid at column index, set True 


    If colIndex >= 0 Then 


      ClickCheckboxGridColumn objGrid, colIndex, True 


    End If




  • Sorry I tried to format the previous post, but seems like I couldn't do anything else. You may want to copy the code to a text editor before reviewing it.

  • Hi,


     


    Viper, Thanks for sharing your code with us. I've modified its formatting.


    Are you using IE 11? Our forum doesn't work properly with this browser version.


     


    Pinky, does Viper's suggestion help you?

  • Ravik's avatar
    Ravik
    Super Contributor
    Hi Pinky,



    Try this code, may help you.




    Sub Test



    Set CheckBoxs = Sys.Browser("iexplore").Page("your URL").FindChild("ObjectType", "Checkbox", 300)



    For each checkbox in CheckBoxs



    checkbox.Click



    Next



    End Sub



     



     


  • @Tanya: properly I used IE 11 for the post yesterday. I have both IE 11 and Chrome. Will try Chrome next time. Thanks for your feedback.