HOME   DOWNLOADS   ORDER ONLINE   CONTACT US



 OVERVIEW
 
 DOWNLOAD
 
 ORDER ONLINE
 
 KNOWLEDGE
 BASE

How to achieve the fastest results with SBList

If you have used the SBList demo program you will have seen that SBList can out-perform the standard Visual Basic list box by almost 100%. This is achieved by using the AutoDraw property which gives you control over the drawing of the list box.

A standard list box refreshes itself automatically after you add or remove an item, and so does SBList when the AutoDraw property is set to true, which is the default setting. However, the nature of a list box means that typically you would add more than just one item to the list at a time, and so there is little point in refreshing the list until it contains all the items that you want to add.

By setting the AutoDraw property to false before you add or remove list items you are allowing SBList to update its contents without having to refresh after each change. For only a few items this doesn't make much difference to the speed, but for longer lists the change is dramatic. Also, because SBList offers you the ability to include images and font changes on each line, it does take slightly longer to populate a list if you take advantage of these features. The AutoDraw property minimises this delay.

The code below will add 224 items to a list taking advantage of the AutoDraw feature:

    SBList1.AutoDraw = False
    For A% = 32 to 256
        SBList1.AddItem "Char " & A% & " is a " & Chr$(A%)
    Next A%
    SBList1.AutoDraw = True
This gives you powerful control over your list. For example, you might have a list showing the results of a database search. When the user starts a new search you can set AutoDraw to false, clear your SBList and add the new results to it while the previous search information remains visible in the list. Once the new search is complete, just update the list by setting AutoDraw back to true. The example below demonstrates this principle:

    Form1_Click()
        Static B%
        SBList1.AutoDraw = False
        SBList1.Clear
        For A% = 1 to 500
            SBList1.AddItem "This is item " & (A% + B%)
        Next A%
        B% = B% + A%
        SBList1.AutoDraw = True
    End Sub
Each time you click the form, the list is updated but only refreshed once the updates are completed.

When the visible property of an SBList is set to false, the AutoDraw feature is ignored and the list does not refresh until it is made visible.

Note: The standard Refresh method does not redraw the list items when AutoDraw is set to false; you must use the AutoDraw method as shown above.

Topic devised by Andy Groom.

 
Copyright © 2000 Global Components. All rights reserved.