Recent

Author Topic: [SOLVED] ListView draw custom checkboxes  (Read 853 times)

SaraT

  • Full Member
  • ***
  • Posts: 139
  • A little student
[SOLVED] ListView draw custom checkboxes
« on: April 23, 2023, 05:03:50 pm »
Hello friends :)

I would like to know if it is porrible to draw custom checksboxes in ListView (vsReport style) control, if so,
how can I do it?

Let's say, load checkboxes images (checked and unchecked) from file or ImageList.

I would appreciate any help.
« Last Edit: April 24, 2023, 05:37:07 am by SaraT »

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: ListView draw custom checkboxes
« Reply #1 on: April 23, 2023, 05:50:46 pm »
Put the checkbox images into an ImageList that you assign to the StateImages of the ListView. Whenever you want to check an item set its StateIndex to the imageindex of the checked checkbox image in this image list; and when you want to uncheck an item do the same with the unchecked image. If you want to toggle items with the mouse you must evaluate the HitTestInfo in the OnMouseDown event.

See the attached sample.

SaraT

  • Full Member
  • ***
  • Posts: 139
  • A little student
Re: ListView draw custom checkboxes
« Reply #2 on: April 24, 2023, 05:37:28 am »
Put the checkbox images into an ImageList that you assign to the StateImages of the ListView. Whenever you want to check an item set its StateIndex to the imageindex of the checked checkbox image in this image list; and when you want to uncheck an item do the same with the unchecked image. If you want to toggle items with the mouse you must evaluate the HitTestInfo in the OnMouseDown event.

See the attached sample.

Thanks, it works perfect!

 

TinyPortal © 2005-2018