Home Forums WinForms controls Xceed Grid for WinForms GetSortedDataRows

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

    In a GroupAdded event I am calling e.Group.GetSortedDataRows(true) but it always returns an empty list – the groups are there but not the row list.

    Also:

    e.Group.GetSortedDataRowCount(

    true) tells me the row count is zero when  the group header tells me there are items in the group (they are clearly there, I can see them buit e,.Group doesn’t appear to know about them)

    I have also tried calling them with false as an argument but it doesn’t make any difference

    How can I fix this?

    Imported from legacy forums. Posted by Jonathan (had 841 views)

    User (Old forums)
    Member
    Post count: 23064

    This is normal since this event is triggered right after the group is created, before it is filled with DataRows.  In fact, if you inspect the EventArgs, you will see that one member is the DataRow that is responsible for creating the group, which can happen only once.  All other DataRows added to this group will not trigger this event.

    You need to use the GroupingUpdated event so that all groups have been completely built before you try to access their DataRowList.

    e.g.:

    private void Form1_Load( object sender, EventArgs e )

    {

        gridControl1.GroupingUpdated +=

    new EventHandler( gridControl1_GroupingUpdated );

    }

    void gridControl1_GroupingUpdated( object sender, EventArgs e )

    {

        foreach( Group group in gridControl1.Groups )

        {

            //Note that groups can contain groups, so you may need to loop on group.Groups also.

            Debug.WriteLine( group.Title + ” “ + group.GetSortedDataRows( false ).Count.ToString() );

        }

    }

     

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

    User (Old forums)
    Member
    Post count: 23064

    Thank you. That did the trick

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

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