Home Forums WinForms controls Xceed Grid for WinForms How to get a list of all rows (including group rows, etc…)

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

    Hello,

     

    I’d like to export a grid to Excel with an external API

    The problem is : when I read the datarows collection, I don’t

    have access to group summary rows at the same time

    and my datarows don’t follow my on-screen grid rows order…

    Is there any other way to access to grid’s cells the way

    they’re painted at screen in the grid ????

    Many thanks !

    Imported from legacy forums. Posted by Allaume (had 968 views)

    User (Old forums)
    Member
    Post count: 23064

    There is no list in the grid that will contain all the rows in it.  However, you could iterate through the different collections in the proper order, and you should be able to accomplish what you want.  Naturally, the collections you need to iterate will depend on how you have built your grid..  You can start with the FixedHeaderRows, which includes the GroupByRow and ColumnManagerRow.  Then if you have no Groups or DetailGrids, you can go directly to the DataRows collection.  If you have added a SummaryRow, at the end of the grid, then you would need to check the GridControl.FooterRows or FixedFooterRows, depending on where you have placed it.

    If you have groups in your grid, you would need to iterate through the Groups collection, in which you would need to iterate through there own HeaderRows, DataRows, and FooterRows.  If you have nested Groups, you would also need to iterate through the Groups in the Group, right after the HeaderRows.

    If you have DetailGrids, you would need to do the same as with the Groups.  The following example shows how to do this, but if you have a complex grid, you will need to increment on it, for instance, use a recursive function to iterate through the nested Groups!

    e.g. :

    foreach( Row row in gridControl1.FixedHeaderRows )

    {

        Debug.WriteLine( row.ToString() );

    }

    if( gridControl1.Groups.Count > 0 )

    {

        foreach( Group group in gridControl1.Groups )

        {

            foreach( Row row in group.HeaderRows )

            {

                Debug.WriteLine( row.ToString() );

            }

            ReadOnlyDataRowList rowList = group.GetSortedDataRows( false );

            foreach( Row row in rowList )

            {

                Debug.WriteLine( row.ToString() );

            }

            foreach( Row row in group.FooterRows )

            {

                Debug.WriteLine( row.ToString() );

            }

        }

    }

    else

    {

        foreach( Row row in gridControl1.DataRows )

        {

            Debug.WriteLine( row.ToString() );

        }

    }

    foreach( Row row in gridControl1.FixedFooterRows )

    {

        Debug.WriteLine( row.ToString() );

    }

     

    Imported from legacy forums. Posted by André (had 580 views)

    User (Old forums)
    Member
    Post count: 23064

    I am using WPF 3.0 Grid and there is no .DataRows collection.

     

    Did you mention that by mistake? 

    Imported from legacy forums. Posted by Koti (had 333 views)

    User (Old forums)
    Member
    Post count: 23064

    You’re in the wrong forum.  This is the Grid for .NET forums, not the DataGrid for WPF one.

    Please post your question here : http://xceed.com/CS/forums/35/ShowForum.aspx

    Imported from legacy forums. Posted by André (had 1013 views)

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