Option Explicit
Private Sub Form_Load()
Dim newRec As ReportRecord
With ReportControl1
.SetCustomDraw (xtpCustomBeforeDrawRow)
.Columns.Add 0, "Add", 100, True
.Columns.Add 1, "Part Name / Component", 200, True
.Columns.Add 2, "Purchase Order Qty", 100, True
.Columns.Add 3, "Production Order Qty", 100, True
.Columns(1).TreeColumn = True
Set newRec = .Records.Add
newRec.AddItem ""
newRec.Item(0).HasCheckbox = True
newRec.AddItem "Car"
newRec.AddItem 2
newRec.AddItem 2
newRec.Item(0).HasCheckbox = True
.Populate
Set newRec = .Rows(0).Record.Childs.Add
newRec.AddItem ""
newRec.Item(0).HasCheckbox = True
newRec.AddItem "Part-A"
newRec.AddItem 4
newRec.AddItem 4
newRec.Item(0).HasCheckbox = True
Set newRec = .Rows(0).Record.Childs.Add
newRec.AddItem ""
newRec.Item(0).HasCheckbox = True
newRec.AddItem "Part-B"
newRec.AddItem 4
newRec.AddItem 4
newRec.Item(0).HasCheckbox = True
Set newRec = .Rows(0).Record.Childs.Add
newRec.AddItem ""
newRec.Item(0).HasCheckbox = True
newRec.AddItem "Part-C"
newRec.AddItem 2
newRec.AddItem 2
newRec.Item(0).HasCheckbox = True
newRec.ParentRecord.Expanded = True
.Columns(1).Editable = False
.Columns(2).Editable = False
.Populate
.AllowEdit = True
End With
End Sub
Private Sub Form_Resize()
ReportControl1.Move 120, 120, Me.ScaleWidth - 240, Me.ScaleHeight - 240
End Sub
Private Sub ReportControl1_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)
If Item.Index = 3 Then Metrics.BackColor = vbYellow
End Sub
Private Sub ReportControl1_ValueChanged(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem)
If Row.RowTreeLevel = 0 Then
Dim rr As ReportRow
Dim multi
multi = Row.Record.Item(2).Caption / Row.Record.Item(3).Caption
For Each rr In Row.Childs
rr.Record.Item(3).Caption = CDbl(rr.Record.Item(2).Caption) / multi
Next
ReportControl1.Populate
End If
End Sub