-
Nov 2nd, 2019, 01:04 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Sort ListView items by checked items at first .
I am using VBCCR listview . I want to sort items to display all checked items at the top when the user checks an item or by a press of a button to do the task in one shot .
Bear in mind that , I want to add the possibility of preserving the checked items even after the listview is re-populated again . I am populating it with a recordset . In the table it reads form , I added a boolean field to save the checked items in the session and then clears all after the form is unloaded . this is not an optimal solution as it costs more overhead especially in large amount of data .
Also , I want a solution to handle this issue even while not using a recordset to populate the listview .
My ultimate goal is , The user may search a recordset and gets back fewer list items than the original count , the he selects (checks) some items and want to see them checked again when the search filter changes . I dont use filter method of listview but I mean filtering the recodset by the where clause . So , the listview now populates new items and forgets all checked items the user checked . I need a solution to handle this in populating with recordset or without it.
-
Nov 2nd, 2019, 07:54 AM
#2
Re: Sort ListView items by checked items at first .
Some ideas
Database: you'll need to store a value to determine whether checked or not in order to preserve that state for the next time the listview is populated
-- when populating from database, you can use Order By to sort on checked state (if wanted)
Other than recordset: you'll likely want to write a file that identifies which items are checked
Sorting ListView: Create a hidden (zero-width) column that only contains a value when item is checked and cleared when it is unchecked. Sort by that column. Alternate method is to semi-manually sort the listview whenever sorting by checked state is needed. You would first sort by your primary column (whatever that is), if needed. Then you would loop thru the listview from bottom to top
- when checked listitem found, move it to the top of the list
-- moving requires insert copied/new item at index #1, then delete the original item
Last edited by LaVolpe; Nov 2nd, 2019 at 08:05 AM.
-
Nov 3rd, 2019, 03:48 AM
#3
Thread Starter
Addicted Member
Re: Sort ListView items by checked items at first .
Thanks Lavolpe , brilliant ideas ,I will give them a try today .
But ,
Then you would loop thru the listview from bottom to top
- when checked listitem found, move it to the top of the list
-- moving requires insert copied/new item at index #1, then delete the original item
How can I insert an item at a specific index when the listview is already populated .
-
Nov 3rd, 2019, 07:29 AM
#4
Re: Sort ListView items by checked items at first .
Originally Posted by Hosam AL Dein
How can I insert an item at a specific index when the listview is already populated .
The 1st parameter in .ListItems.Add is the optional index
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|