This is a migrated thread and some comments may be shown as answers.

RadGridView: loop through cells

1 Answer 502 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Evelyn
Top achievements
Rank 1
Evelyn asked on 23 Sep 2015, 06:54 PM

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

}

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 28 Sep 2015, 08:54 AM
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.

Regards,
Martin Vatev
Telerik
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
Tags
GridView
Asked by
Evelyn
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or