Click to See Complete Forum and Search --> : Maintain a ListView


April 8th, 1999, 02:34 AM
Hi,

I have a problem, where I need to make my listview app more robust, since users
INSERT/REMOVE/CHANGE items as they please. I have an array of structs, which is where I store the data displayed in the listview. So when there's been some action, to update the view, I use:
{
CListCtrl& listCtrl = GetListCtrl();
int item = listCtrl.GetNextItem(-1,LVNI_ALL|LVNI_SELECTED);
int num = listCtrl.GetItemCount();
[....modify item.....]
listCtrl.RedrawItems(1,num);
UpdateWindow();
}
This is in case of modify.
Deleting I remove the structure from the array in memory, and then from the
listview, then I use:
.
.
listCtrl.RedrawItems(1,num -1);
UpdateWindow();
And for adding an item I use
.
.
listCtrl.RedrawItems(1,num +1);
UpdateWindow();

I am basically just asking for some "tips" as to how, maintain a robust listview
I would not want to demo anything less.

And I have a menu that looks similar to my ContextMenu in IDR_MAINFRAME, and this menu's commands should only be executed if an item is selected.
How do I do this?

Thanx.