RadGridView: loop through cells

2 posts, 0 answers
  1. Evelyn
    Evelyn avatar
    18 posts
    Member since:
    Mar 2015

    Posted 23 Sep 2015 Link to this post

    I would like to go through every cell in a RadGridView and see if its value is equal to a string.
    It should work like a find tool (ctrl + f). The user type something and I try to find what was typed in the cells. Is there anyway of doing this? Or a easiest way? 

    if(text == cell.value)


        //do whatever I want


  2. Martin Vatev
    Martin Vatev avatar
    130 posts

    Posted 28 Sep 2015 Link to this post

    Hi Evelyn,

    Please note, that RadGridView utilizes UI virtualization mechanisms. Thus it initializes visual items only for those items that would fit in the current view port. To read the cell values for all of the items we recommend to do that on the data-level. This can be achieved through the Items collection of RadGridView. You can see the code snippets below:

    foreach (var item in this.grid.Items)
                    foreach (var column in grid.Columns.OfType<GridViewBoundColumnBase>())
                        if (text ==  column.GetValueForItem(item).ToString())
                            //do whatever you want

    I hope this helps.

    Martin Vatev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top