Download VB5 User's Guide
Transcript
Fg3.AddItem "*" + t + "Meals" s = "" +t+ "Flint’s BBQ" +t+ "25-Apr-95" +t+ "35.00" For i = 0 to 5 Fg3.AddItem s Next Fg3.AddItem "*" +t+ "Hotel" s = "" +t+ "Center Plaza" +t+ "25-Apr-95" +t+ "817.00" For i = 0 to 5 Fg3.AddItem s Next ’ Add up totals and format heading entries. For i = Fg3.Rows - 1 To 0 Step -1 If Fg3.TextArray(i * Fg3.Cols) = "" Then tot = tot + Val(Fg3.TextArray_(i * Fg3.Cols + 3)) Else Fg3.Row = i Fg3.Col = 0 Fg3.ColSel = Fg3.Cols - 1 Fg3.CellBackColor = &HC0C0C0 Fg3.CellFontBold = True Fg3.CellFontWidth = 8 Fg3.TextArray(i * Fg3.Cols + 3) = Format(tot, "0") tot = 0 End If Next ’ Select the first row. Fg3.Col = 1 Fg3.Row = 1 Fg3.ColSel = Fg3.Cols - 1 End Sub At run time, the rows are sorted into three divisions under their respective headings: Air Fare, Meals, and Hotels. Add Collapsing and Expanding Functionality To add functionality which allows the row headings to be expanded or collapsed, add the following code to the control’s DblClick event procedure: Sub Fg3_DblClick () Dim i As Integer, r As Integer ’ Ignore top row. r = Fg3.MouseRow If r < 1 Then Exit Sub ’ Find field to collapse or expand. While r > 0 And Fg3.TextArray(r * Fg3.Cols) = "" r = r - 1 Wend