# ListBoxes

**URL:** <https://forum.xojo.com/t/listboxes/47280>\
**Category:** General\
**Created:** [February 8, 2019, 2:01pm UTC](https://forum.xojo.com/t/listboxes/47280 "2019-02-08T14:01:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Hallock](https://forum.xojo.com/user_avatar/forum.xojo.com/rob_hallock/32/734_2.png) [@Rob\_Hallock](https://forum.xojo.com/u/Rob_Hallock)\
**Post date:** [February 8, 2019, 2:01pm UTC](https://forum.xojo.com/t/listboxes/47280/1 "2019-02-08T14:01:09Z")

</div>

I’m starting to realize that ListBox might be able to do much more than the basic examples offered in the docs…

For example, I like alternating row colours. I also like a horizontal line between row items but the stock listbox properties don’t have alternating row colours and the line are too ‘severe’ …

I like it ‘softer’ like this example.

![](https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?raw=1)

I don’t know how to make images show up in this forum… this is the link  
[https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?dl=0](https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?dl=0)

This is how I made it:

Add event CellBackgroundPaint to your list box and then some code similar to this:

```auto
' ensure there are list items
If Me.ListCount > 0 Then 

	If IsDarkMode = False Then ' dark mode can make your color choices look bad so use different ones when dark mode is on.

		' change the background color of alternate rows to light cyan when dark mode is off
		If row Mod 2 = 0 Then
			g.ForeColor = &cC0EDF4
			g.FillRect(0, 0, g.Width, g.Height)
		End If

		' draw subtle light gray horizontal lines between the rows (much softer than the default listbox property)
		g.ForeColor = &c808080 'e0e0eb
		g.DrawLine(g.Height - 18 , 0, g.Width, 0)

	Else

		' draw dark grey horizontal lines between the rows when dark mode is on 
		g.ForeColor = &c1f1f2e
		g.DrawLine(g.Height - 18 , 0, g.Width, 0)

	End If 

End If 
```

Edit (Paul): Fixed image URL.

---

<div class="post-metadata">

**Author:** ![Paul\_Lefebvre](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_lefebvre/32/3152_2.png) [@Paul\_Lefebvre](https://forum.xojo.com/u/Paul_Lefebvre)\
**Post date:** [February 8, 2019, 2:11pm UTC](https://forum.xojo.com/t/listboxes/47280/2 "2019-02-08T14:11:40Z")

</div>

Very nice! This page also covers a lot of the things you can do with ListBox:

[https://documentation.xojo.com/topics/user\_interface/desktop/desktop\_controls/list\_box.html](https://documentation.xojo.com/topics/user_interface/desktop/desktop_controls/list_box.html)

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [February 8, 2019, 2:14pm UTC](https://forum.xojo.com/t/listboxes/47280/3 "2019-02-08T14:14:24Z")

</div>

If you want to link an image from dropbox just take the download link:

[https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?dl=0](https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?dl=0)

and change the end part to

raw=1

[https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?raw=1](https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?raw=1)

then surround it in the [img] tags by clicking the little button at the top right of the post.

![](https://www.dropbox.com/s/tv5qjgmeclvdsls/list.png?raw=1)

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:33pm UTC](https://forum.xojo.com/t/listboxes/47280/4 "2020-10-29T19:33:07Z")

</div>


