$include "Qlistviewex.inc"

dim form as qform
with form
.center
end with


' First. We create a new QlistviewEx                  |  - First Steps -
dim list as qlistviewex


' We set the parentpanel Parent window                |
list.Parentpanel.parent = form


' then align the parentpanel to the whole client area |
' (but we could align it in any way)                  |
list.parentpanel.align = 5


' To put other components we use the Draw method.     |
' the draw method is VERY important, because it's used|
' to update the QlistviewEx layout                    |
list.draw


'Ok, now it's time to add some columns. Please note:  |  - Adding Columns -
'if you want the component to run correctly you have  |
'to use this method instead of the normal addcolumns  |
'as this method updates the Columns_Count property too|
list.addcol "First Name/Last Name/City"

' Generally, csv files use ";" as column separator,   |  - Separator -
' but sometimes we need to import files or streams    |
' Which use different separators, like "/" or "," or  |
' strings like "<thisisacolumnseparator>".            |
' this is the purpose of the Separator property:      |
' before loading a file, write this                   |
list.Separator = "/"


'Now we want to load some data in the listview. We    |  - Loading data -
'could use the file included in this package called   |
'database.csv.
list.csvFile = "database.csv"
list.loadfromcsvfile

'You see, columns are a bit narrow, so we would like  |  - Columns width -
'to do something like this :                          |

list.column(0).width = 100
list.column(1).width = 100
list.column(2).width = 100

' And then call the draw method. By the way... have   |
' you already clicked on column headers ?!?  Yes, they|
' start automatic sorting                             |
list.draw


' Maybe we don't want REDs in our list                |  - Excluding items -
list.exclude(1, "red")

' Oh, sorry, we don't want WHITEs                     |  - Reloading data -
list.load
list.exclude (1, "White")

' As long as the program is "alive" (and as long as   |
' you don't change csv) the csv property will keep the|
' original data, so you can use the load method to    |
' reload data from memory                             |

' Now we want to keep only REDs                       |  - Filtering -

list.filter (1, "Red")

' ** NOTE ** Filter and exclude are NOT case sensitive|
' so RED or Red or red or rEd is the same             |

' Now we have to sort items by City. We have 2 ways   |  - Sorting -
' 1 - Click on the "City" column header               |
' 2 - Use the sortby method                           |

list.sortby ("City")

' Unlike filter and exclude Sortby is CASE SENSITIVE  |


' =================================================================|
' Changing layout and other capabilities                           |
' =================================================================|

' You can use QlistviewEx as a common Qlistview       |
' component, so you can add/delete items and subitems |
' as usual


' The "complex" structure of the QlistviewEx component|  - Header -
' allows a lot of extra properties/capabilities. For  |
' Example, if we want to change the header layout we  |
' can treat it as a common Qpanel:                    |

list.header.bevelinner = 1
list.header.color = rgb(20,145,200)
list.header.height = 25
list.header.font.size = 10

' or maybe we don't want to see it...                 |
list.header.visible = 0

' ParentPanel is a Qpanel, so we can do things like   |  - ParentPanel -
list.Parentpanel.align = 1
list.Parentpanel.height = 180


' Column headers are Qcoolbtn, so we can add icons,   |  - Column headers -
' and things like that                                |
list.Colheader(0).bmp = "Star.bmp"
list.draw

' if we don't want flat column headers we just write  |
list.flatheaders = 0
list.draw

' if we want only the first column header to be flat  |
' then:                                               |
list.colheader(0).flat = 1

' ** NOTE ** this property will be overwritten every  |
' time you call the draw method ...                   |


' IMPORTANT. You can change column headers caption    |
' using the .colheader.caption property, but this is  |
' not the correct way. If you want the QlistviewEx to |
' run properly, you must set column width and caption |
' using the QlistviewEx.Column() property and then    |
' call the DRAW method.


' When you manipulate hundreds of items, and you want |  - Fastclear -
' to clear the Qlistview, if you use the clear method |
' you will have to wait some minutes with a slow pc.  |
' in cases like this you can use the Fastclear method |
list.fastclear

' remember: it's not necessary if you have small lists|