ListBox CellBackgroundPaint Doesn't Repaint

I am creating a wizard to import a text file into a ListBox that the user will match columns up to a list of defined names to the columns using a PagePanel. The number of pages in the Page Panel is set by the number of columns in the ListBox and I have a button control set that has a button on every page to advance through the page panel pages. In the ListBox CellBackgroundPaint event I have the following code to highlight the column:

If Me.ColumnTag(column) = "highlight" Then g.ForeColor = &cc0c0c0 g.FillRect(0, 0, g.Width, g.Height) End If

That works fine on the open event for column 0 that I set to a ColumnTag that is already set to “highlight”. What I cannot seem to get the ListBox to do is repaint when I change the ColumnTag of another column and set it to “highlight” and set the previously set ColumnTag to another value. The PushButton on each page Panel has this code to advance the page and call a method to change the ColumnTag:

[code]
Dim i,n As Integer
i = Me.PanelIndex
n = PagePanel_Wizard.PanelCount

If Not (i = n - 1) Then
PagePanel_Wizard.Value = i + 1
HighlightColumn(i) //Starts on panel 0 advances to panel 1 and highlights column 0, etc.
End If[/code]

The method HighlightColumn has this code:

[code]
HighlightColumn(ColNum As Integer)

Dim i,n As Integer

For i = 0 To Listbox1.ColumnCount - 1
Listbox1.ColumnTag(i) = ColumnList(i)
Next

Listbox1.ColumnTag(ColNum) = “highlight”

Listbox1.Refresh(True)[/code]

I have also tried Listbox1.Invalidate but nothing seems to make the ListBox repaint with the highlight color.

Any suggestions? Should I be doing this another way?

First to stop the framwork from overwriting your color after fillRect do:
Return True

To Get it to redraw do:

me.InvalidateCell(-1,oldColumn)
me.InvalidateCell(-1,NewColumn)

THANK YOU KAREN!!!

It’s always something simple I missed. I appreciate the quick replay. It works beautifully now. :smiley: