« REAL Studio Summit 20… | Home | Video about Atlanta: … »

Two Listbox Control Tips

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 Boolean
dim b as Boolean = me.CellTag(row, kColumnTagDisabled)

if b then
g.ForeColor = &c777777
g.ForeColor = &c000000
end if
End Function
Second 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:
  Function CompareRows(row1 as Integer, row2 as Integer, column as Integer, ByRef result as Integer) As Boolean
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)

Return true
end if
End Function
I hope you have use for this :-)
28 11 10 - 21:59
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.