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";
        }
    }
}

For Each rowInfo As GridViewRowInfo In RadGridView1.Rows
    For Each cellInfo As GridViewCellInfo In rowInfo.Cells
        If (cellInfo.ColumnInfo.Name = "Title") OrElse (cellInfo.ColumnInfo.Name = "FirstName") OrElse (cellInfo.ColumnInfo.Name = "LastName") Then
            cellInfo.Value = "Test Value"
        End If
    Next
Next

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.

See Also

In this article