Home Forums WPF controls Xceed DataGrid for WPF iteration over datarows equivilent

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #27207 |

    How do I iterate over each row in the grid currently?

     

     

    Imported from legacy forums. Posted by Val (had 972 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Val,

    You could try this out: 

                foreach (object item in TestGrid.Items)
                {
                    Xceed.Wpf.DataGrid.DataRow dr = TestGrid.GetContainerFromItem(item) as Xceed.Wpf.DataGrid.DataRow;
                }

    where TestGrid is your Xceed DataGridControl.

    Just one thing to take note, this method only returns the rows after the Grid is initialized and rendered. I tried looping through this during the initialization of the grid, and even though there are already the items in the datagrid, the datarow object was not yet created 

    Cheerios,

    Serene
     

    Imported from legacy forums. Posted by Serene (had 779 views)

    User (Old forums)
    Member
    Post count: 23064

    Actually this looks like it was what I wanted.  Thanks though, it pointed me in the right direction. 

    foreach

    (System.Data.DataRow dr in dgvCourses.Items)
    {

    if (dr != null)

    total +=

    decimal.Parse(dr[4].ToString());

    }

    Imported from legacy forums. Posted by Val (had 984 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.