BB_ListBox_RowData class
Methods
BB_ListBox_ExtraData class
Constructor (RowArray() as String)
Constructor (RowArray() as String, ExtraDataArray() as BB_ListBox_ExtraData)
e.g rowData.Append New BB_ListBox_RowData(Array("Grand Blanc", "1000", "???"))
rowData.Append New BB_ListBox_RowData(Array("Bad Axe", "2000", "???"))
ListBox1.AddFolder("Michigan", rowData)
rowData2Extra.Append New BB_ListBox_ExtraData
rowData2Extra(0).SubRow_CellAlignment = ListBox.AlignCenter
rowData2.Append New BB_ListBox_RowData(Array("Cleveland", "1000", "???"), rowData2Extra)
rowData2.Append New BB_ListBox_RowData(Array("Columbus", "2000", "???"), rowData2Extra)
ListBox1.AddFolder("Ohio", rowData2)
Each item in the BB_ListBox_RowData array holds all the data for a single row. The first example above adds 2 rows of 3 columns each.
Optionally you can add formatting for the sub-rows by adding an array of BB_ListBox_ExtraData. The second example above adds 2 rows of 3 columns each with the first column having centered text.
Bens_ListBox_Extras class
Events
CellAction (row as Integer, column as Integer, PopupX as Integer, PopupY as Integer)
The CellAction event has been enhanced to include parameters for the x and y location (relative to the parent Window) of the top corner of the cell. These are only populated if the CellType has been defined as TypePopupMenu.
e.g ListBox1.CellType(5, 2) = ListBox1.TypePopupMenu
CellBackgroundPaint (g As Graphics, row As Integer, column As Integer, scalingFactor as Double)
The CellBackgroundPaint includes a scalingFactor paramater. Custom code in the CellBackgroundPaint is printed as the scalingFactor parameter allows this custom drawing code to be printed correctly when the PageSetup has been set to print to the maximum dpi of the printer (see the Print method below).
HandleException (MethodName As String, Error As RuntimeException)
This event is the exception handler for all the subclass' methods.
Methods
Add a row and store the sub rows
AddFolder (Item as String, SubItems() as BB_ListBox_RowData, Optional ExpandRow as Boolean)
This is an extension to the standard ListBox AddFolder method which allows definition and storage of sub-rows (only 1 deep currently). The additional data and its formatting is provided by adding an array of BB_ListBox_RowData (see BB_ListBox_RowData class info above). The rows are normally collapsed but can be set to expanded by setting the optional ExpandRow to true.
Cell Tags
BB_CellTag (Row as Integer, Col as Integer) As Variant
BB_CellTag (Row as Integer, Col as Integer, CellTag as Variant)
BB_CellTag is a replacement for the CellTag as this is now used by the BB_ListBox_ExtraData class. Please do not use CellTag as this will cause problems!
Get or Set the Cell Back Color
CellBackColor (Row as Integer, Col as Integer) As Color
CellBackColor (Row as Integer, Col as Integer, BackColor as Color, Optional ShowColorWhenSelected as Boolean)
The odd/even row color is returned unless there is a custom cell background color set. Setting the (optional) ShowColorWhenSelected allows the color to show through as a colored circle when the row is selected.

Set the Cell Control and its position
CellControl (Row as Integer, Column as Integer, CellControl as RectControl, Optional Left as Integer, Optional Top as Integer)
e.g. ListBox1.CellControl(ListBox1.LastIndex, 1, ProgressBar1)
These methods allow setting of a RectControl in any cell and any position. Setting Left to -1 will draw the text to the left of the control, all other values (0 is the default) will draw the text to the right of the control. Setting Top to -1 (the default) will draw the control in the center of the cell.
Clicking on the control will fire the CellAction event. The menu for the PopupMenu and changing the source control are handled internally by the class.
NOTE! Only BevelButtons, Checkboxes and PopupMenus (currently) will receive clicks and press the control.
DO NOT make your window Composite. There is a bug in REALbasic 2009r5.1 and lower which causes the controls to be drawn in the window titlebar (which probably will oly be fixed when Cocoa is delivered).
Get or Set Cell Pictures and their position
CellPicture (Row as Integer, Column as Integer) As Picture
CellPicture (Row as Integer, Column as Integer, Pic as Picture, Optional Left as Integer, Optional Top as Integer)
e.g. ListBox1.CellPicture(5, 2, Doc, ListBox1.CellPicture_ImageAfterText, 3)
These methods allow setting of a Picture in any cell and any position. If Left is not set then the picture is drawn to the left of the cell and the text will then be aligned to be to the left of the picture. By using CellPicture_ImageAfterText constant for the Left the image will be drawn to the right of the current text
Get or Set the cell's Text Color
CellTextColor (Row as Integer, Col as Integer) As Color
CellTextColor (Row as Integer, Col as Integer, TextColor as Color)
These methods get or set the Cell Text Color.
Get or Set the cell's Font
CellTextFont (Row as Integer, Col as Integer) As String
CellTextFont (Row as Integer, Col as Integer, FontName as String)
These methods get or set the Cell Text Font.
Get or Set the cell's Font Size
CellTextFontSize (Row as Integer, Col as Integer) As Integer
CellTextFontSize (Row as Integer, Col as Integer, FontSize as Integer)
These methods get or set the Cell Text Font Size.
Get or Set the enable/disable mouse clicks in a particular cell
Cell_SuppressClick (Row as Integer, Col as Integer) As Boolean
Cell_SuppressClick (Row as Integer, Col as Integer, NoClick as Boolean)
These methods get or set the enable/disable for mouse clicks firing on clicking on a cell.
Printing the contents of the ListBox
Print (Settings as PrinterSetup, Optional parentWind as Window, Optional HeaderPic as Picture, Optional FooterPic as Picture, Optional ScaleToFitWidth as Boolean)
This method prints the contents of the ListBox (on multiple pages if necessary). The parentWind allows the Print dialog to appear as a sheet in the given window (on MacOS X). HeaderPic and FooterPic allow custom Headers and Footers to be printed on each page. By setting ScaleToFitWidth to true the listbox will be scaled up (maintaining the correct H x W ratio) to fit on the page.
Printing also supports high resolution printers (i.e anything larger than the "normal" screen resolution of 72 or 96 dpi). If any images are used in cells then these are scaled up or down depending on their set dpi. To print at high resolution all that is required is to set the MaxHorizontalResolution and MaxVerticalResolution in the page setup so it determines the maximum dpi. From the example file:
ps=New PrinterSetup
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1
Resize the column widths to the largest text
ResizeCol (Col as Integer)
This will resize the given column to the longest text in that column. This does NOT include any text beyond a carriage return.
Determine if the row has a disclosure triangle
Row_HasDisclosureTriangle (row as Integer) As Boolean
Properties
BB_RowHeight as Integer: Get or Set the Default Row Height. This returns the height (in pixels) of a single ListBox row. Setting it to -1 will auto-size the rows, it will NOT return -1 but the updated row height. This property is a replacement for "DefaultRowHeight" as it does not work properly with the change to allow different heights for Cells and Headers (see TextFont and TextSize below).
DrawRowBackPastLastCol As Boolean: Workaround for REALbasic bug (fixed in RB2009r1) to allow drawing the row background color past the last column (like iTunes)
BB_HeaderHeight As Integer: Gets the height of the header
HighlightStyle As Integer: Sets the selected row highlight style of the listbox. 0 - Normal RB ListBox selection color, 1 - Mac Style, 2- Blue gradient (like MacOS X v10.5 Finder), 3 - Gray gradient (like MacOS X v10.5 Mail)
Row_EvenColor As Color: Set the background color of even rows. This is overridden by colors set by the CellBackColor method.
Row_OddColor As Color: Set the background color of even rows. This is overridden by colors set by the CellBackColor method.
SuppressHeaderClicks As Boolean: Stop mouse clicks in the ListBox header
SuppressHeaderClicksAllowColResize As Boolean: Stop mouse clicks in the ListBox header but allow the columns to be resized
Replacements for TextFont and TextSize
The following properties for Cells and Headers are replacements for the RB ListBox TextFont and TextSize. These can get or set the size or font at runtime or in the IDE. Do not use the TextFont and TextSize properties at runtime (they have been disabled in the IDE properties).
DefaultCellTextFont As String
DefaultCellTextSize As Integer
HeaderTextFont As String
HeaderTextSize As Integer