Page 1 of 1

Listbox with checkboxes

Posted: 16 Jun 2011, 18:01
by andromeda
This control looks really great. Just a question from a newbie, how do you put the checkboxes in the listbox?

Many thanks

Re: Listbox with checkboxes

Posted: 17 Jun 2011, 07:36
by TiKu
Hi,

The native listbox control of Windows does not support checkboxes. For such a requirement a listview is the better choice. Take a listview, set it to Details view, make it hide the header, insert a column and then the items. You can make the column width equal the control width minus the control's border or you can make it autosize to the widest item.

The alternative is to make the listbox ownerdrawn and draw the checkboxes yourself. The Fonts and Colors sample demonstrates how to owner-draw a listbox.

Regards
TiKu