Print Page | Close Window

Sample for MergeCell and Grouping Subtotal

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=16362
Printed Date: 26 September 2024 at 12:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sample for MergeCell and Grouping Subtotal
Posted By: McKloony
Subject: Sample for MergeCell and Grouping Subtotal
Date Posted: 06 March 2010 at 10:15am
Is there any sample for the new MergePreviousVerticalCells and GroupFormula subtotals?

-------------
Product: Xtreme SuitePro (ActiveX) 16.2.5

Platform: XP / Windows 7

Language: Visual Basic 6.0 SP6



Replies:
Posted By: SuperMario
Date Posted: 27 May 2010 at 3:36pm
Merged cells:


Option Explicit

Private Sub Form_Load()
Dim column As ReportColumn
Dim item As ReportRecordItem

   With Me.ReportControl1
      Set column = .Columns.Add(.Columns.Count, "1", 50, True)
      column.Editable = False
      column.Sortable = False
      column.Alignment = xtpAlignmentWordBreak
      column.HeaderAlignment = xtpAlignmentWordBreak Or xtpAlignmentCenter
     
      Set column = .Columns.Add(.Columns.Count, "2", 200, True)
      column.Sortable = False
      column.Alignment = xtpAlignmentWordBreak
      column.HeaderAlignment = xtpAlignmentWordBreak Or xtpAlignmentCenter
     
      Set column = .Columns.Add(.Columns.Count, "3", 50, True)
      column.Sortable = False
      column.HeaderAlignment = xtpAlignmentWordBreak Or xtpAlignmentCenter
     
      With .Records.Add
         .AddItem ""
         Set item = .AddItem("CodeJock MFC and ActiveX products ")
         item.MergePreviousCells = 1
         item.Alignment = xtpAlignmentVCenter Or xtpAlignmentCenter
         .AddItem ""
      End With
      With .Records.Add
         Set item = .AddItem("Platform ")
         Set item = .AddItem("MFC, ActiveX")
         .AddItem ""
      End With
      With .Records.Add
         .AddItem ""
         Set item = .AddItem("Calendar, Command Bars, Controls, Docking Pane")
         .AddItem ""
      End With
      With .Records.Add
         Set item = .AddItem("Codejock products for MFC and ActiveX developers ")
         item.MergePreviousVerticalCells = 1
         item.Alignment = xtpAlignmentWordBreak
        
         Set item = .AddItem("Property Grid, Report Control, Shortcut Bar, Skin Framework, Syntax Edit, Task Panel")
         .AddItem ""
      End With
      With .Records.Add
         .AddItem ("Next row")
         .AddItem ("Next item")
         .AddItem ""
      End With
      With .Records.Add
         .AddItem ("Last row")
         .AddItem ("Last item")
         .AddItem ""
      End With
     
      .AllowEdit = True
      .FocusSubItems = True
      .StrictBestFit = True
      .PaintManager.FixedRowHeight = False
      .PaintManager.DrawGridForEmptySpace = True
      .PaintManager.HorizontalGridStyle = xtpGridSolid
      .PaintManager.VerticalGridStyle = xtpGridSolid
      .PaintManager.GridLineColor = RGB(192, 192, 255)
      .PaintManager.AllowMergeCells = True
      .PaintManager.ColumnStyle = xtpColumnOffice2007
      .PaintManager.ForceShowTooltip = True
      .ToolTipContext.Style = xtpToolTipOffice2007
      '.PaintManager.UseColumnTextAlignment = True
      '.FreeHeightMode = True
      .AllowColumnReorder = False
      .AllowColumnSort = False
      .AllowColumnRemove = False
      .ShowGroupBox = False
      .CreateRowNumberColumn 10
      .EnableDragDrop "MergeReport", xtpReportAllowDragMove Or xtpReportAllowDrop
      .Populate
   End With
End Sub

Private Sub Form_Resize()
    Me.ReportControl1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub


Posted By: SuperMario
Date Posted: 27 May 2010 at 3:37pm
Sub totals in group row:

Option Explicit

Private Sub Command_Click()
    wndReport.Populate
End Sub

Private Sub Form_Load()
    Dim xColumn As XtremeReportControl.ReportColumn
    Dim i As Integer
   
    Set xColumn = wndReport.Columns.Add(0, "Product", 100, True)
    wndReport.Columns.Add 1, "State", 100, True
    wndReport.Columns.Add 2, "Sales", 100, True
    wndReport.Columns.Add 3, "Q-ty", 100, True
    wndReport.Columns.Add 4, "", 100, True
       
    Dim xRecord As XtremeReportControl.ReportRecord
    Dim xRecordItem As XtremeReportControl.ReportRecordItem
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Pen")
    Set xRecordItem = xRecord.AddItem("NSW")
    Set xRecordItem = xRecord.AddItem(20)
    Set xRecordItem = xRecord.AddItem(1)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("paper")
    Set xRecordItem = xRecord.AddItem("NSW")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(2)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Books")
    Set xRecordItem = xRecord.AddItem("NSW")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(3)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Pen")
    Set xRecordItem = xRecord.AddItem("SA")
    Set xRecordItem = xRecord.AddItem(20)
    Set xRecordItem = xRecord.AddItem(4)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("paper")
    Set xRecordItem = xRecord.AddItem("SA")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(5)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Books")
    Set xRecordItem = xRecord.AddItem("SA")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(6)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Pen")
    Set xRecordItem = xRecord.AddItem("WA")
    Set xRecordItem = xRecord.AddItem(20)
    Set xRecordItem = xRecord.AddItem(7)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("paper")
    Set xRecordItem = xRecord.AddItem("WA")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(8)
'-------------------------------------------
    Set xRecord = wndReport.Records.Add
    Set xRecordItem = xRecord.AddItem("Books")
    Set xRecordItem = xRecord.AddItem("WA")
    Set xRecordItem = xRecord.AddItem(10)
    Set xRecordItem = xRecord.AddItem(9)
'-------------------------------------------
'Demo for usual rows formula
'    Set xRecord = wndReport.Records.Add
'    Set xRecordItem = xRecord.AddItem("All")
'    Set xRecordItem = xRecord.AddItem("Total")
'    Set xRecordItem = xRecord.AddItem("x")
'    xRecordItem.Format = "%d"
'    'xRecordItem.Formula = "SUMSUB(R1C2:R9C3)" - this is for child records
'    'xRecordItem.Formula = "SUMSUB(R*C2:R*C3)"
'    xRecordItem.Caption = "x"
'    xRecordItem.Formula = "SUM(R*C2:R*C3)"
'    xRecordItem.Editable = False
'
'    Set xRecordItem = xRecord.AddItem("x")
'    xRecordItem.Format = "%d"
'    'xRecordItem.Formula = "SUMSUB(R1C2:R9C3)" - this is for child records
'    'xRecordItem.Formula = "SUMSUB(R*C2:R*C3)"
'    xRecordItem.Caption = "x"
'    xRecordItem.Formula = "SUM(R*C3:R*C4)"
'    xRecordItem.Editable = False
   
    With Me.wndReport
        .PaintManager.ColumnStyle = xtpColumnOffice2007
        '.PaintManager.TreeStructureStyle = xtpTreeStructureSolid
        .SortRecordChildren = True
        .AllowColumnSort = True
        .AllowColumnReorder = True
        .AllowEdit = True
        .FocusSubItems = True
        .ShowGroupBox = True
        .ShowItemsInGroups = True
        .HideColumnAfterGroupBoxDrop = False
    End With
   
    wndReport.IconViewRowNumberSetup 3, 0, 1, 20
    wndReport.PaintManager.RecOrRowNumber = False
    wndReport.PaintManager.StartRecOrRowNumber = 1
    wndReport.Columns.Find(2).TreeColumn = True
    wndReport.PaintManager.TreeIndent = 40

    wndReport.PaintManager.GroupIndentColor = RGB(255, 255, 255)
    wndReport.PaintManager.FormulaSumColor = RGB(0, 255, 255)
    wndReport.ShowRowNumber (True)
   
    wndReport.GroupsOrder.Add xColumn
    wndReport.Populate
    wndReport.ReCalc True
   
    Dim row As ReportRow
    Dim groupRow As ReportGroupRow
    For i = 0 To wndReport.Rows.Count - 1
        Set row = wndReport.Rows(i)
        If row.groupRow Then
            Set groupRow = row
                'groupRow.GroupFormat = " [SubTotal $=%.02f]"
                groupRow.GroupFormat = "%.02f"
                'groupRow.GroupFormula = "SUMSUB(R*C2:R*C4)" 'Old notation
                groupRow.GroupFormula = "SUMSUB(C2:C3) SUMSUB(C3:C4)" 'New (short) notation
                groupRow.GroupCaption = "x"
        End If
    Next
   
myerror:
    If Err.Number > 0 Then
        MsgBox Err.Description
    End If
    
End Sub

Private Sub Form_Resize()
    wndReport.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub


Private Sub wndReport_GroupOrderChangedEx(ByVal Column As XtremeReportControl.IReportColumn, ByVal Reason As XtremeReportControl.XTPReportColumnOrderChangedReason)
    Dim i As Integer
    Dim row As ReportRow
    Dim groupRow As ReportGroupRow
    Dim xRecord As XtremeReportControl.ReportRecord
    Dim xRecordItem As XtremeReportControl.ReportRecordItem

    If Reason & xtpReportColumnAddedToGroupby Then
        For i = 0 To wndReport.Rows.Count - 1
            Set row = wndReport.Rows(i)
            If row.groupRow Then
                Set groupRow = row
                    'groupRow.GroupFormat = " [SubTotal $=%.02f]"
                    groupRow.GroupFormat = "%.02f"
                    'groupRow.GroupFormula = "SUMSUB(R*C2:R*C3)"
                    groupRow.GroupFormula = "SUMSUB(C2:C3) SUMSUB(C3:C4)"
                    groupRow.GroupCaption = "x"
                    'groupRow.GroupCaption = "ABC [2]12.1 [3]15.2"
            End If
        Next
        wndReport.ReCalc True
    End If
   
'    If Reason & xtpReportColumnGroupOrderChanged Then
'        For i = 0 To wndReport.Rows.Count - 1
'            Set row = wndReport.Rows(i)
'            If row.groupRow Then
'                Set groupRow = row
'                    'groupRow.GroupFormat = " [subTotal $=%.02f]"
'                    groupRow.GroupFormat = "$%.02f"
'                    'groupRow.GroupFormula = "SUMSUB(R*C2:R*C3)"
'                    groupRow.GroupFormula = "SUMSUB(C2:C3) SUMSUB(C3:C4)"
'                    'groupRow.GroupCaption = "x"
'            End If
'        Next
'        wndReport.ReCalc True
'    End If
End Sub




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net