# List box when displayed event

**URL:** <https://forum.xojo.com/t/list-box-when-displayed-event/88648>\
**Category:** Getting Started\
**Created:** [July 22, 2026, 8:40pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648 "2026-07-22T20:40:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glenn\_Rathke](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/df705f/32.png) [@Glenn\_Rathke](https://forum.xojo.com/u/Glenn_Rathke)\
**Post date:** [July 22, 2026, 8:41pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/1 "2026-07-22T20:41:00Z")

</div>

As a list is being loaded with data, through code or maybe directly from DBKit, how can I change the color of a row or cell, or perform some calcuation. I’m really wanting to know how or where to put the code to do ‘something’ when a row is being displayed. At this point, I don’t care if it slows down the loading, I just need to figure out whre things are or how to do the,

Thanks

Glenn

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [July 22, 2026, 8:59pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/2 "2026-07-22T20:59:40Z")

</div>

First question is: What target? Desktop or Web?

---

<div class="post-metadata">

**Author:** ![Glenn\_Rathke](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/df705f/32.png) [@Glenn\_Rathke](https://forum.xojo.com/u/Glenn_Rathke)\
**Post date:** [July 22, 2026, 9:27pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/3 "2026-07-22T21:27:55Z")

</div>

Yes, I should have stated desktop.

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [July 22, 2026, 9:32pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/4 "2026-07-22T21:32:25Z")

</div>

You can add a RowTag for the row you’re currently performing an action on, something like

```auto
myList.AddRow( "Cell 1", "Cell 2", "Cell 2" )
myList.RowTagAt( myList.LastAddedRowIndex ) = True

```

Then, in myList’s PaintCellBackground event:

```auto
If row < 0 or row > me.LastRowIndex then Return

If me.RowTagAt( row ) = True Then
  g.DrawingColor = &cFF00FF
  g.FillRectangle( 0, 0, g.Width, g.Height )
  Return True
End If

```

And, finally, at the end of your process that loads your data, you can set that row’s tag to False to display the default colors.

---

<div class="post-metadata">

**Author:** ![Christian\_Wheel](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_wheel/32/20536_2.png) [@Christian\_Wheel](https://forum.xojo.com/u/Christian_Wheel)\
**Post date:** [July 23, 2026, 2:39am UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/5 "2026-07-23T02:39:53Z")

</div>

One tip to speed up the loading, set your Listbox.Visible property to false before you begin loading and modifying rows, then set it back to True once the update is complete. It saves repeated painting operations until the very end.

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [July 23, 2026, 7:15am UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/7 "2026-07-23T07:15:10Z")

</div>

It can look odd if populating the ListBox takes too long. Usually, disabling the vertical scrollbar while populating it is sufficient. If I recall correctly, Xojo has configured the framework so that the ListBox only draws the visible content in this scenario.

---

<div class="post-metadata">

**Author:** ![Glenn\_Rathke](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/df705f/32.png) [@Glenn\_Rathke](https://forum.xojo.com/u/Glenn_Rathke)\
**Post date:** [July 23, 2026, 5:07pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/8 "2026-07-23T17:07:23Z")

</div>

All I am really asking for if is there an even when a row is loaded when using the DBKit. It not using thast, then you just laod the rows through code. As far as changing colors or calculations, they are coming form a business rule collection I have sspecific to a role each users has. e.g. a user with the role of Admin may want to hiighlight a row or cell in red if the invoice is past due for 60 days. A different user with a different role may want to display past due invoice in yello. It’s just the even I am looking for. Once I have that I will do what needs to be done. An even using the DBKit, or no.?

Thanks for the hints

Glenn

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [July 23, 2026, 5:54pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/9 "2026-07-23T17:54:21Z")

</div>

In the ListBox’s paint events you can set colours for any cell, based on any logic you want. There are the following events, you can simply set a colour and allow xojo to carry on, or handle the drawing all on your own:

- PaintCellBackground
- PaintCellText

Does that help?

---

<div class="post-metadata">

**Author:** ![Glenn\_Rathke](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/df705f/32.png) [@Glenn\_Rathke](https://forum.xojo.com/u/Glenn_Rathke)\
**Post date:** [July 23, 2026, 6:19pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/10 "2026-07-23T18:19:27Z")

</div>

YES! That is a huge help. One more question as I become familiar with this, for the row that is being displayed, how can I read the contents from another cell in the current row that is being loaded?

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [July 23, 2026, 6:41pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/11 "2026-07-23T18:41:38Z")

</div>

CellTextAt( row, column ). But you can also have a RowTagAt or CellTagAt that can hold information in raw format so you don’t have to decode a text version of the cell. These don’t show in the interface but are very useful.

For example if a column is a date the cell will still contain text, but you could store the true DateTime object in the CellTag for the row. Then you can do maths like date subtraction etc, rather than having to convert the text back to a DateTime every time a paint event occurs. Equally, you could just load a result into the CellTag at load time. So as you load the data set a RowTag to True / False and simply check RowTagAt(…) = true set colour to red.

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [July 23, 2026, 7:38pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/12 "2026-07-23T19:38:30Z")

</div>

> [@Sascha\_S](#):
>
> disabling the vertical scrollbar while populating it is sufficient

This. Just as effective if not more so than making the LB invisible.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [July 23, 2026, 8:01pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/13 "2026-07-23T20:01:32Z")

</div>

How long do you code with Xojo ?

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [July 23, 2026, 8:26pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/14 "2026-07-23T20:26:04Z")

</div>

Moi?

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [July 23, 2026, 9:40pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/15 "2026-07-23T21:40:13Z")

</div>

No Julia, OP… what he wrote looks like he started recently, not 14 years ago…

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [July 23, 2026, 9:56pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/16 "2026-07-23T21:56:29Z")

</div>

Yes, OP is probably new; CellPaint in ListBox is something most learn early on. Me, since 2002.

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [July 23, 2026, 9:59pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/17 "2026-07-23T21:59:51Z")

</div>

Well we are in the Getting Started category 😁  
Perfect place for the OP’s questions 👍

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [July 24, 2026, 3:56am UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/18 "2026-07-24T03:56:16Z")

</div>

> [@brian\_franco](#):
>
> Well we are in the Getting Started category 😁

Of course, you are right.

Note that OP is here since 2013-11-02.  
(click in an user logo and read what appears)

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [July 24, 2026, 12:33pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/19 "2026-07-24T12:33:06Z")

</div>

I did see the join date but try and remember people have different situations in life. OP could have stepped away from programming due to work or life situations and now coming back. Many situations for people 😁

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [July 24, 2026, 12:46pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/20 "2026-07-24T12:46:08Z")

</div>

I’m not sure why it matters anyway. Not everyone is familiar with every part of the system. If they want help, we help. I for example have never touched the mobile systems. I’ve only ever done Web1 not Web2.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [July 24, 2026, 6:51pm UTC](https://forum.xojo.com/t/list-box-when-displayed-event/88648/21 "2026-07-24T18:51:55Z")

</div>

> [@brian\_franco](#):
>
> people have different situations

That’s it.

Knowing (or having an idea) of the OP user allows to give an appropriate answer.

A old poster (with Xojo) may just need a simple answer with a link to the documentation while a newbie may need a … newbie answer (more documented answer).

Of course, a clear description leads to a good answer (better answer).

The question let me think “he’s a newbie”, but this can only be because OP does not ask often here and do not know what is important, etc.

Behind the paragraph (the question), many answers can be done. That is why I checked the joined date. But it does not helped me enough…

[Next page](https://forum.xojo.com/t/list-box-when-displayed-event/88648.md?page=2)
