New to Telerik UI for WinForms? Download free 30-day trial

Iterating Cells

You can iterate through the cells of each row using the Cells collection of GridViewCellInfo. The example below firstly iterates the rows of the grid, then the cells for each row:

foreach (GridViewRowInfo rowInfo in radGridView1.Rows)
{
    foreach (GridViewCellInfo cellInfo in rowInfo.Cells)
    {
        if ((cellInfo.ColumnInfo.Name == "Title")
            || (cellInfo.ColumnInfo.Name == "FirstName")
            || (cellInfo.ColumnInfo.Name == "LastName"))
        {
            cellInfo.Value = "Test Value";
        }
    }
}

RadGridView uses virtualization for its visual elements. This means that only the rows that are currently visible have a visual element. When the grid is scrolled up and down the visual elements are reused. Because of the virtualization, it is safe to use the CellElement only inside the CellFormatting event and only for the current cell.