|
-
Jun 14th, 2008, 10:50 PM
#1
Thread Starter
Member
[RESOLVED] Add a filter to a listview
I have a listview and some data and i would like to use some filters
For example: Show all records with id>14
Is there any way to do that?
Thanks in advance.
-
Jun 14th, 2008, 11:00 PM
#2
Re: Add a filter to a listview
Not without custom coding it yourself. Under some cases it may require comparing a value from every single item in the listview and that can be very memory intensive.
Here is an example
Code:
Dim Tmp As Long
Dim I As Long
Tmp = ListView1.ListItems.Count
For I = 1 To Tmp
If ListView1.ListItems(I).Index > 50 Then
ListView1.ListItems.Remove I
I = I - 1
Tmp = Tmp - 1
If I = Tmp Then Exit For
End If
Next
Last edited by Mxjerrett; Jun 14th, 2008 at 11:03 PM.
If a post has been helpful please rate it. 
If your question has been answered, pull down the tread tools and mark it as resolved.
-
Jun 14th, 2008, 11:25 PM
#3
Re: Add a filter to a listview
ComCtl32 Header Control has a FilterBar that will allow you to specify filters for individual columns.
Unfortunately it is not available in the Vb6 ListView.
http://www.vbaccelerator.com/home/VB...ol/article.asp
You can add this header control to VbAccelerator sGrid2:
http://www.vbaccelerator.com/home/vb..._2/article.asp
Based on column filter, Hide/Show Rows in the Grid.
Code:
Public Enum cgFilterFlag
cgFilterNone
cgFilterEqual '=
cgFilterNotEqual 'Not=
cgFilterGreaterEqual '>=
cgFilterGreater '>
cgFilterLessEqual '<=
cgFilterLess '<
cgFilterWildcard '* and/or ?
End Enum
-
Jun 15th, 2008, 12:05 AM
#4
Thread Starter
Member
Re: Add a filter to a listview
 Originally Posted by Mxjerrett
Not without custom coding it yourself. Under some cases it may require comparing a value from every single item in the listview and that can be very memory intensive.
Here is an example
Code:
Dim Tmp As Long
Dim I As Long
Tmp = ListView1.ListItems.Count
For I = 1 To Tmp
If ListView1.ListItems(I).Index > 50 Then
ListView1.ListItems.Remove I
I = I - 1
Tmp = Tmp - 1
If I = Tmp Then Exit For
End If
Next
Cool!
Thanks!!
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
|