Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subitems in ListView Redux
Message
From
15/02/1999 16:02:28
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Subitems in ListView Redux
Miscellaneous
Thread ID:
00187800
Message ID:
00187800
Views:
53
Last week I posted a couple of messages looking for help with adding subitems to a listview control. The silence my question generated (other than Bela's) forced me to sort it out for myself, which was not all bad... though a very slow process.

For future reference incase anyone ever wants to do this, the process is pretty simple.

1. Using the Listview's property sheet, define the column headers, widths and captions, to instantiate the subitems array. This can also be done in code.

2. Set the listview's view setting to 3 (report view)

3. Press the 'apply' button several times until the settings finally stick. Sometimes I have to go in and out of the property sheet a few times before it realizes I'm serious about saving the settings.

4. Then in your code something like this:

Thisform.ListView.ListItems.Add(,"_1","First Item")
Thisform.ListView.ListItems(1).SubItems(1) = "Column Two"
Thisform.ListView.ListItems(1).SubItems(2) = "Column Three"

etc

5. The total number of subitems you can add is your number of defined columns - 1. If you go over you generate one of those meaningful OLE errors.

6. You can add images to your rows using the ImageList control and with the following code at the top of your method:

Thisform.ListView.SmallIcons = Thisform.ImageList.Object

Then add your ListItem followed by:

Thisform.ListView.ListItems(1).SmallIcon = "key_name_of_image"


That's all there is to it. Doing the column headers, widths and captions in code is also fairly straight forward. If anyone wants to know more, contact me.

Dale
Next
Reply
Map
View

Click here to load this message in the networking platform