We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

foreach loop

Is it possible to iterate through all the cells of the grid with a foreach loop? If not, is there a recommended alternative process to do when we want to iterate through all the cells?

2 Replies

AD Administrator Syncfusion Team June 26, 2006 05:37 PM UTC

Hi Jesse, No, It is not possible to iterate through all the cells of the grid with a foreach loop. You can use this code to iterate all the cells in a grid. Here is a code snippet. for(int i = 0 ;i <= this.grid.Model.RowCount;i++) { for(int j=0;j< this.grid.Model.Colcount;j++) { //To acess the cell using this code. Console.WriteLine (this.grid.Model[i,j].Text); } } Let me know if this helps. Best Regards, Haneef


JM Jesse Marek June 26, 2006 07:12 PM UTC

Thanks. The code works great. (It''s a <= in both for loops, though.) >Hi Jesse, > >No, It is not possible to iterate through all the cells of the grid with a foreach loop. You can use this code to iterate all the cells in a grid. Here is a code snippet. > >for(int i = 0 ;i <= this.grid.Model.RowCount;i++) >{ > for(int j=0;j< this.grid.Model.Colcount;j++) > { > //To acess the cell using this code. > Console.WriteLine (this.grid.Model[i,j].Text); > } >} > >Let me know if this helps. >Best Regards, >Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon