Databound Listbox

Is it possible to create something like a “databound listbox” that just reacts on the event “celltextpain” without defining its content with addRow.

I tried to set the maximum row but the lastIndex property is readonly.
Is there another way?

[quote]Is it possible to create something like a “databound listbox” that just reacts on the event “celltextpain” without defining its content with addRow.[/quote]You would have to subclass listbox and implement it yourself.

LastIndex is the index of the last added or inserted row.

thanks

I try to subclass listbox.
The thing that doesn´t work, is that “cell text paint” isn´t called. I think because the listbox has no rows.
How can I tell my listbox how many rows it has?

In the subclass you need to events:

Function NumberOfRows As Integer Function ValueAtRowAndColumn(row As Integer, column As Integer) As String
In the CellTextPaint event you need to:

  • call NumberOfRows and add rows with AddRow (or remove them with RemoveRow)
  • then call ValueAtRowAndColumn to get the string to display

Now as you mentioned CellTextPaint will not be called if there are no rows, so you will always need a row 0, which you can add in the Open event.

Sorry, I don´t understand.
What for do I need the Function NumberofRows if I have to call I myself and call AddRow.