Home Forums WinForms controls Xceed Grid for WinForms Calculations in groups TitleFormat?

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

    Hi,

    is it possible to do basic calculations in the groups TitleFormat property? I want to do (sum of ColumnA) – (sum of ColumnB) for the whole group and show the sum in the groups title.

    twi

    Imported from legacy forums. Posted by twi (had 1958 views)

    User (Old forums)
    Member
    Post count: 23064

    This is not possible by setting the TitleFormat property. You will need to do this manually on each title property of each group. You can use the GroupingUpdated event to do this, so it works at form load and when the user drags columns to the GroupByRow. You can also change the title in the SiblingDataRowsChanged event, so that if DataRows are added or removed from a group, the title updates.

    e.g.:

    private void Form1_Load(object sender, System.EventArgs e)
    {
    groupManagerRow1.TitleFormat = “%GroupTitle%”;
    gridControl1.GroupingUpdated += new EventHandler(gridControl1_GroupingUpdated);
    groupManagerRow1.SiblingDataRowsChanged += new EventHandler(groupManagerRow1_SiblingDataRowsChanged);
    }

    private void gridControl1_GroupingUpdated(object sender, EventArgs e)
    {
    foreach( Group group in gridControl1.Groups )
    {
    ReadOnlyDataRowList list = group.GetSortedDataRows( false );
    int countEmployee = 0;
    int countShipVia = 0;
    foreach( Xceed.Grid.DataRow row in list )
    {
    countEmployee += ( int )row.Cells[ “EmployeeID” ].Value;
    countShipVia += ( int )row.Cells[ “ShipVia” ].Value;
    }
    gridControl1.Groups[ 0 ].Title = “Result for this group : ” + ( countEmployee – countShipVia ).ToString();
    group.Title = “Result for this group : ” + ( countEmployee – countShipVia ).ToString();
    }

    private void groupManagerRow1_SiblingDataRowsChanged(object sender, EventArgs e)
    {
    ReadOnlyDataRowList list = ( ( GroupManagerRow )sender).ParentGroup.GetSortedDataRows( false );
    int countEmployee = 0;
    int countShipVia = 0;
    foreach( Xceed.Grid.DataRow row in list )
    {
    countEmployee += ( int )row.Cells[ “EmployeeID” ].Value;
    countShipVia += ( int )row.Cells[ “ShipVia” ].Value;
    }
    ( ( GroupManagerRow )sender).ParentGroup.Title = “Result for this group : ” + ( countEmployee – countShipVia ).ToString();
    }

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

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