Re: TreeViews - How to save?
- Posted by 10963508 at europeonline.com Aug 18, 2002
- 487 views
Hi, So the problem is that you don't know how to associate listview items with one treeview item? When treeview item is clicked, you want to show its associated items in listview. In one program I wrote I did it like this: I had global sequence which had strings, full paths, for all folders (items) in treeview, like this: This is our example treeview: -root -item1 -item1_child1 -item1_child2 -item2 -item2_child1 In that treeview above that global sequnce with full paths would look like this: sequence Treeview_paths = { "root", "root\\item1", "root\\item1\\item1_child1", "root\\item1\\item1_child2", "root\\item2", "root\\item2\\item2_child1" } Then when treeview item is clicked (w32HChange event for treeview) I get full path for clicked item, I wrote one routine for getting that. So if "item1_child1" was clicked: sequence clicked_item_path = "root\\item1\\item1_child1" Then I get index of clicked folder, like this: integer folder_index = find (clicked_item_path, Treeview_paths) Now that you know how to get index of clicked folder you know how to associate listview items with folders. You can have another global sequence which will have data for listview items for every folder index, like this: sequence Listview_items_data = { { -- this is data for "root" treeview item {"listview item 1", 1, 2, 3, some your data...}, {"listview item 2", 1, 2, 3, some your data...}, ... }, { -- this is data for "root\\item1\\item1_child1" treeview item {"listview item 1", 1, 2, 3, some your data...}, {"listview item 2", 1, 2, 3, some your data...}, ... }, . . . } C programmers and non-Win32Lib programmers do this different and it works faster: They save pointer to listview items array into lParam of treeview items. Win32Lib has defineUserProperty() ... functions but I don't know if they work with treeview items (I think they don't) , plus they are not so fast like saving/retrieving simple pointer. ----- Original Message ----- From: "Tony Steward" <lockmaster67 at aol.com> To: "EUforum" <EUforum at topica.com> Sent: Sunday, August 18, 2002 2:30 AM Subject: TreeViews - How to save? > > Hello all, > I have not used TreeViews until know. > > How can I save the structure of a TV. > > How I think I will use it. > I have a large ListView and beside it I will create the TV. The user > will be able to create branches on the TV and assign item from the LV to > that branch so in the future the whole LV will not need to be loaded. > Only the items that the users attached to the branch on the TV. (Hope > this makes sense) > > Thanks > Tony > > Give your hardest tasks to your lasiest workers. > They will always find the easiest way to complete it. > > > >