New to Telerik UI for WinFormsStart a free 30-day trial

Iterating Cells

Updated over 6 months ago

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:

C#
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.

See Also

In this article
See Also
Not finding the help you need?
Contact Support