* * *

Author Topic: Painting a Icon in ListView in vsreport mode  (Read 549 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 570
Painting a Icon in ListView in vsreport mode
« on: October 29, 2018, 12:16:01 pm »
Hi, I have a small application to show same information. See the image attached.
I will like use a Icon in "Tipo" column.
How can i do it?
I see this example in stackflow but I couldn't work it on Lazarus 2.0 RC1.
https://stackoverflow.com/questions/6612797/delphi-how-to-draw-small-icons-in-list-view-on-customdrawitem
Any Idea?
Thanks
« Last Edit: October 29, 2018, 01:12:19 pm by BlueIcaro »
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

jamie

  • Hero Member
  • *****
  • Posts: 908
Re: Painting a Icon in ListView in vsreport mode
« Reply #1 on: October 29, 2018, 05:57:29 pm »
each TlistItem has a ImageIndex, StateIndex etc in it.

You can create a TImageList, add the images you want to it and tell the ListView/TreeVew to use that ImageList.

When you load your list, you need to specify the Image index for the listItem that is in that column.
 
 I believe you can specify two image indexes so that you can have a different image depending on the state (StateIndex)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 570
Re: Painting a Icon in ListView in vsreport mode
« Reply #2 on: November 02, 2018, 02:01:21 pm »
each TlistItem has a ImageIndex, StateIndex etc in it.

You can create a TImageList, add the images you want to it and tell the ListView/TreeVew to use that ImageList.

When you load your list, you need to specify the Image index for the listItem that is in that column.
 
 I believe you can specify two image indexes so that you can have a different image depending on the state (StateIndex)
How can I specify the image?, Using any event?
/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

jamie

  • Hero Member
  • *****
  • Posts: 908
Re: Painting a Icon in ListView in vsreport mode
« Reply #3 on: November 02, 2018, 02:50:24 pm »
you change the image index value of the node?

 The images are referenced from a TimageList. each image you put in will represent the state you want.

 so pick what ever event you want to use in the list and set the ImageIndex value in the Node to reflect the
the condition you would like..
 
  For example, if the row was locked you could put an image of a LOCK there , just change the ImageIndex..

 
  I don't know how else to explain it to you.

 P.S. node/Listitem

« Last Edit: November 02, 2018, 02:57:02 pm by jamie »

lucamar

  • Sr. Member
  • ****
  • Posts: 316
Re: Painting a Icon in ListView in vsreport mode
« Reply #4 on: November 02, 2018, 03:28:41 pm »
How can I specify the image?, Using any event?
/BlueIcaro

You can, indeed, use almost any event but the best place to do it is when you create/add the TListItem or, if needed, when a list item changes its state.

You should read the documentation for TListView and TListItem.
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 570
Re: Painting a Icon in ListView in vsreport mode
« Reply #5 on: November 02, 2018, 04:12:17 pm »
you change the image index value of the node?

 The images are referenced from a TimageList. each image you put in will represent the state you want.

 so pick what ever event you want to use in the list and set the ImageIndex value in the Node to reflect the
the condition you would like..
 
  For example, if the row was locked you could put an image of a LOCK there , just change the ImageIndex..

 
  I don't know how else to explain it to you.

 P.S. node/Listitem

Thanks for your info. I did it as you say and it's works
I assigned a image to the item as I created.
Same thing like this:
Code: [Select]
     ListItem := Items.Add;
      Listitem.Caption := 'Name' + IntToStr(I);
      ListItem.ImageIndex := 1;
      Listitem.SubItems.Add('Second name');
/BlueIcaro

How can I specify the image?, Using any event?
/BlueIcaro

You can, indeed, use almost any event but the best place to do it is when you create/add the TListItem or, if needed, when a list item changes its state.

You should read the documentation for TListView and TListItem.
This example: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ComCtrls_TCustomListView_Items.html was very useful for me

/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus