Cannot see populated listbox data

Hi,

As you can see in the below code, I’m trying to draw a rectangle in the cell. It works well, and no problem to see the rectangle and the row value.
The problem is that I don’t see other column values in Listbox.
Without implementing ‘rectangle feature’, I see the all column values populated in Listbox correctly.

It has taken me several hours, but I can’t find the bug.

Can you check this code?

PopulateListbox

  While Not rs.EOF
    dataList.AddRow("")
    
    For i As Integer = 1 To dataList.ColumnCount - 1
      dataList.Cell(dataList.LastIndex, i) = rs.IdxField(i).StringValue
      
      If i = 7 Then 'PRINCE status
        
        Dim p as New Picture(100,40,32)
        p.Graphics.ForeColor = &C92B92C
        p.Graphics.FillRect(0,0,100,40)
        p.Transparent=1
        
        dataList.CellTag(dataList.LastIndex,i) = p
        
      End If
      
    Next
    
    rs.MoveNext
  Wend
  
  Datalist.Refresh

CellTextPaint

[code] g.ForeColor = &c647D84

If column = 7 Then
dim p as Picture = me.CellTag( row,column )
g.DrawPicture p,0,0
g.DrawString me.cell(row,column),x,y

End If

Return true
[/code]

You want colored Text?

CellTextPaint

If column = 7 Then g.ForeColor = &c647D84 End If

I wanted to draw a rectangle and draw a string on it.
The problem is that after implementing this one, I can’t see other column values.

In CellTextPaint, you are always returning True to indicate you are overriding the text drawing all the time. But actually you only override the text drawing when column = 7. So put the Return True within the If…End If, not outside of it:

  If column = 7 Then
    g.ForeColor = &c647D84
    dim p as Picture = me.CellTag( row,column )
    g.DrawPicture p,0,0
    g.DrawString me.cell(row,column),x,y
    Return true  
  End If

All right. I see. I understand that now.

It works very well.
Thanks a lot.