How to set space between items in a checked list b

2019-02-17 08:00发布

问题:

I'm developing a windows form application using c#. How can I set a space between items in a checked list box?

回答1:

You can't, increasing the font size is all you got. Not exactly a control that's suitable for a touch screen. You can re-implement it with ListBox.DrawMode and ControlPaint.DrawCheckBox().

The better selection here is a ListView with View = Tile, easy to hit with your thumb when you make the tile big enough. You can't use ListView.CheckBoxes anymore, using an icon is a good choice. Also automatically takes care of the user only selecting one item.



回答2:

Looks like you could go with a ListView (which always always always ist the better choice anyway) and a (dummy) imagelist. See here and here.

Just tried it and it's really easy: Add an imagelist to your form; set its imagesize width to something small and its height to your liking and apply it as the listview's stateimagelist. No need for any actual images.

No need to go for tiles and you could add prices in a 2nd column, even with a different font.. ListView rules ;-)

Let us see the final result! Yumm!!