Forum Discussion

lalit_singh's avatar
lalit_singh
Contributor
2 years ago
Solved

iterating delphi stringgrid in testcomplete

I need to access values of the columns in StringGrid in delphi How can I access it
  • KB1's avatar
    2 years ago
     

     

    In TestComplete, you can access the values of the cells in a StringGrid control by using the Cells property of the StringGrid object. The Cells property is a two-dimensional array of strings, where the first dimension represents the row index and the second dimension represents the column index.

    For example, to access the value of the cell at row 3 and column 2, you can use the following code:

     

     
    var
      CellValue: string;
    begin
      CellValue := StringGrid1.Cells[2, 3];
    end;

    You can also use a loop to iterate through all cells in the grid and access their values. For example:

     

    var
    
      i, j: Integer;
    begin
      for i := 0 to StringGrid1.RowCount - 1 do
        for j := 0 to StringGrid1.ColCount - 1 do
          Log.Message(StringGrid1.Cells[j, i]);
    end;

     

    This will log the value of each cell in the grid to the log window.

    I hope this helps! Let me know if you have any questions.