Home Forums WinForms controls Xceed Grid for WinForms What event triggers a Summary Row Calculation?

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

    I have an unbound grid that has a summary row (invisible) and a Value row that shows the resulting values.

    Now here’s my question.
    WHEN do I go through and get the Value Row to show the calculated values?
    My current code is returning 0.0 because the summary row hasn’t been run yet.

    Here’s my code;
    Private Sub Set_CommonGroupings()
    ‘// CLEAR ANY CURRENT GROUPS.
    GridControl1.GroupTemplates.Clear()

    ‘// ADD THE CATEGORY GROUPING.
    Dim t_CatGroup As New Xceed.Grid.Group
    Dim t_CatGrpMan As New Xceed.Grid.GroupManagerRow

    t_CatGroup.GroupBy = “Category”
    t_CatGrpMan.TitleFormat = “%GroupTitle%”
    t_CatGroup.HeaderRows.Add(t_CatGrpMan)
    GridControl1.GroupTemplates.Add(t_CatGroup)

    ‘// CREATE THE SUMMARY ROW FOR THE CATEGORIES…
    Dim t_SumCell As Xceed.Grid.SummaryCell
    Dim t_SumRow As New Xceed.Grid.SummaryRow
    t_SumRow.Visible = False
    t_CatGroup.FooterRows.Add(t_SumRow)

    Dim i As Integer = 0
    For i = Col0 to Col10
    t_SumCell = t_SumRow.Cells(i)
    Select Case i
    Case 1,3,8,9
    t_SumCell.StatFunction = Xceed.Grid.StatFunction.None
    Case Else
    t_SumCell.StatFunction = Xceed.Grid.StatFunction.Sum
    End Select
    t_SumCell = Nothing
    Next

    ‘// CREATE THE VALUE ROW TO ACTUALLY SHOW THE VALUES.
    Dim t_ValCell As Xceed.Grid.ValueCell
    Dim t_ValRow As New Xceed.Grid.ValueRow
    t_ValRow.VisibleWhenCollapsed = True
    t_CatGroup.FooterRows.Add(t_ValRow)

    ‘// COMMIT THE GROUPING.
    GridControl1.UpdateGrouping()

    ‘// NOW AFTER THE GROUPS HAVE BEEN CREATED, SET THE VALUE CELLS.
    i = 0
    For i = cSL_NAME To cSL_FULLFUND
    t_ValCell = t_ValRow.Cells(i)
    Select Case i
    Case 8,9
    ‘— NOTHING!
    Case 1
    t_ValCell.Value = t_CatGrpMan.Title & ” Total”
    Case 3
    Dim t_Min As Integer = 0
    Dim t_Max As Integer = 0

    t_SumCell = t_SumRow.Cells(i)
    t_SumCell.StatFunction = Xceed.Grid.StatFunction.Minimum
    Application.DoEvents()
    t_Min = t_SumCell.Value
    t_SumCell.StatFunction = Xceed.Grid.StatFunction.Maximum
    Application.DoEvents()
    t_Max = t_SumCell.Value

    t_ValCell.Value = t_Min & “-” & t_Max

    Case Else
    t_ValCell.Value = t_SumRow.Cells(i).Value
    End Select
    Next

    End Sub

    Imported from legacy forums. Posted by Rock (had 3048 views)

    User (Old forums)
    Member
    Post count: 23064

    You will need to query the SummaryCell in the Application.Idle event, because the StatFunction is run at the latest possible moment.

    I’m not sure why you use a ValueRow to display the SummaryCell result, you could simply display the SummaryRow and let it display the result.

    One other solution would be to make your calculation yourself, not using the SummaryRow, so you could have your result earlier in the event chain than the Application.Idle event.

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

    User (Old forums)
    Member
    Post count: 23064

    The summary row is limited to showing mathematical results (with labels in the next cell)
    The Value Row can show complex values and populated formulas like a range of Min-Max. Getting the string result like “Min-Max” is easy, but I can’t display it with a summary cell. With a summary cell, I can only show the min or the max, not both.
    That’s where the Value Row comes into play.

    …..Unless I’ve completely missed something, which is also an option.

    As for the non-summaried question;
    I’m still working on it, but since the grid will rarely change, using the application.idle event doesn’t seem like a good option.

    I have a calculation routine in place right now but it uses the Summary Row. I think once I break that down and calculate that myself, I’ll have it resolved. The problem only comes into play when I add \ remove groups during run-time, that in turn add \ remove summary rows and value rows.

    Imported from legacy forums. Posted by Rock (had 528 views)

    User (Old forums)
    Member
    Post count: 23064

    “The problem only comes into play when I add \ remove groups during run-time, that in turn add \ remove summary rows and value rows”

    That’s when the Application.Idle could come into play, that is, when groups have been added, SummaryRows are also added, calculation are performed, and you can get the result in the Idle event to update the ValueRows.

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

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