Information générale
Catégorie:
Contrôles ActiveX en VFP
Titre:
Subitems in ListView Redux
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement