Bamboozled - Canvas Paint Issue

Hi, this one has got me bamboozled. The following code is in the paint event of a canvas and should draw rectangles the same width of each of the columns in a listbox (lvwTransactions) one after the other from left to right. It seems to draw the first three then stack the rest on top of each other or something.

[code] Dim leftPos as Integer

for N as integer = 0 to lvwTransactions.ColumnCount - 1


leftPos = leftPos + lvwTransactions.Column(n).WidthActual

next N[/code]

In principle I am trying to draw my own header row for a listbox so the canvas above is the header row and the header row of the listbox is hidden.

Just used that code and it’s looking fine for me - a five column listbox makes five rectangles.

Can you try setting the colour different for each one so you can be sure it’s stacking them? (i.e. if n mod 2 = 0 then g.forecolor = &cCC0000 else g.forecolor = &cCCCCCC end if)


Ditto here.
Are any of your columns a negative width?

No but I am using * widths on 2 of them but widthActual should return the correct width in pixels

Don’t ask, dumb day. I didn’t have the canvas fixed to the right of my window so I could only see the boxes up to the width of the canvas. It’s always those little things that stump you.

How do I delete this thread … Ahhhgghh!!!

Click “Who can view this discussion” on top of the thread and simply add yourself. Nobody but you will see it :wink:

Too Late, we have now all seen it. :slight_smile: :slight_smile:

Next time :wink: