Mirroring a listbox and an array

I need to constantly mirror the contents of a listbox to an array so array(x) always contains the very updated stuff of row(x), actually it is supposed to be an array of cRows where cRow is a class containing all the data a row can contain including tags. The idea is to access that array rather than the listbox to read data (from a thread). I have already work on that but I am a bit unsure how to be sure any update (new row, cell update, cell tag update, row tag update…) will be caught so the array will always be 100% accurate… I find weird the Listbox hasn’t any ‘modified’ or so event…

Thanks, Stan

CellTextChanged for cells tells you when they have been changed by you or edited by the user, and use a method to set the other attributes, so you can update the arrays each time you touch the values. Simple.

The LR says this ‘Occurs after the KeyDown event if the KeyDown event returns False.’ for ‘CellTextChange’. Most of my listbox is updated thru code, not by the user actually…

Well another idea is to use Data-On-Demand Listbox by Kem Tekinay. I have used it on one app of mine, with great results. The pros of using a virtual listbox is that your data-source can by anything you want. My data-source was a class with the data, for which I had some listbox functions (AddRow, etc). You won’t have any ThreadAccess exceptions that way.

You can override all these in a subclass to track 'em.

AddRow (multiple to override)

Changes from EditCell can be captured in CellAction.

You might also need to implement DragReorderRows and/or DropObject. A hierarchical lb will also need ExpandRow/CollapseRow.

Is there anything else that changes data? Column Sorting?

I wonder if instead of mirroring the Listbox’s data you refactor to have a central Model that the Listbox is a View of and the Thread can access. Sounds like maybe the Data-On-Demand Listbox would fit with this. Your model would BE the array of cRow’s so there’s no repackaging.

How do you override ‘Cell’ since it is a getter and a setter at the same time?

If your listbox is updated through code, you just have to update your arrays each time your code changes the listbox. No need for any event.

[code]Function cell(row As Integer, column As Integer) As String
return super.cell(row,column)
End Function

Sub Cell(row As Integer, column As Integer, assigns value as String)
End Sub[/code]

When you have a Listbox subclass and you add a method to it the “Method Name” field is actually a combobox. Click on that arrow and it’ll list all the methods to override. Makes it easy to get the signatures correct.