I have recently been getting very frustrated with the Listview common control, esp some of its formatting capabilites and decided to write my own - which looks similar in some ways to Manos' grid control. Its been coming along very nicely, I can now format the individual cells in any way i feel like (see pic) through a WM_NOTIFY event (similar to the way the common control works with a few more bells and whistles).
The big question that is holding me up at the moment is how to give the display data to the control...for instance if i load a list of strings from a file into an array - would it be easier/better/more flexible to just pass a pointer whole array to the control - or for it to send a message (maybe a WM_NOTIFY) when it needs a cells data, which would be more like the virtual listview. I want to keep the data stored outside of the control so that sorting would be as simple as sorting the array and then repainting the control. Any thoughts?
Posted on 2003-05-11 02:29:28 by MurkyT
Posted on 2003-05-11 08:07:20 by comrade
I would go for a model-view-controller (MVC) implementation, a virtual list-view looks a lot like that. With MVC, you have a view (the UI, look-and-feel), a model (the data to be represented) and a controller that binds the model and view together. Basically, the view can request data from the model with the functions the model supplies (like getValue(row,column)). That way the data is stored only in one place in any format the user likes, as long as it provides the functions to retrieve this information. Usually the model also has a way to notify the view when its data has changed, so that the view is always viewing the right data. This method is pretty efficient and can support many thousands of items. It's a bit more work to use it than providing functions like setValueAt or insertRow etc. but you could provide a default model to give the user both options.

Posted on 2003-05-11 08:21:56 by Thomas
Thanks Thomas - I'll give that idea some thought
Posted on 2003-05-11 10:51:35 by MurkyT