Interested in two practical tips for the listbox control in REAL Studio?
First if you like to change the text color for certain rows in your listbox, you can do like this:
In a celltag I store whether the row should be painted in gray instead of normal black. So I have an celltag in a column in use for this status value. Now for each CellTextPaint event I have my code lookup that value and set the fore color. As I don't return true here, the default REAL Studio code will draw the text for me. But it will not change the color, so my color setting applies. And as you see I use kColumn* constants to define which column has which content. This way I have a central point in each window where I define the column indexes.
Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As BooleanSecond I have a column with a date value and I want to sort them correctly. Normally you do several comparisons to fill the result property with -1, 0 or 1. Now the date class in this case has a Operator_Compare method which returns exactly what I need here. So this code looks quite simple:
dim b as Boolean = me.CellTag(row, kColumnTagDisabled)
if b then
g.ForeColor = &c777777
g.ForeColor = &c000000
Function CompareRows(row1 as Integer, row2 as Integer, column as Integer, ByRef result as Integer) As BooleanI hope you have use for this
if column = kColumnDate then
dim d1 as date = me.CellTag(row1, kColumnDate)
dim d2 as date = me.CellTag(row2, kColumnDate)
result = d1.Operator_Compare(d2)