has anyone ever managed to draw a picture across the entire width of a ListBox row by hacking, regardless of how many columns it has? My approach was to clear the background of all columns using ClearRect (macOS) and then draw the image in the first row, but the area is still limited to the column width. I also tried drawing the picture in the last column and using the negative width of all previous columns as x coordinate. Unfortunately this doesn’t work either.
CellBackgroundPaint
[code]If row = 0 Then
g.ClearRect(0, 0, g.Width, g.Height)
If column = 0 Then
Dim colors(2) As Pair
colors(0) = 0.0 : &c19191900
colors(1) = 0.5 : &cF2F2F200
colors(2) = 1.0 : &cF2F2F200
Dim p As Picture = CreateGradient(MyListBox.Width, g.Height, colors)
g.DrawPicture(p, 0, 0)
You should create and update a Picture with the full listbox width and column height during resized events and then do a drawpicture with the current portion of the cached picture in the cellBackgoundPaint event (in other words use the additional parameters to define the picture source area to copy from).
That’s a very, very clever suggestion. Now I fail once more because of the DrawPicture parameters. For the first two columns the intermediate result looks quite good. With the remaining columns I probably fail again because of mathematics. Here my code - suggestions?
If column = 0 Then
If Pic = Nil Then
Pic= CreateGradient(Me.Width, Me.DefaultRowHeight, Colors)
End If
g.DrawPicture(Pic, 0, 0)
Else
g.DrawPicture(Pic, 0, 0, Me.Column(column).WidthActual, 21, Me.Column(column-1).WidthActual) ' wrong code
End If
Graphics.DrawPicture(Image As Picture, x As Double, y As Double [,destWidth As Double ] [, destHeight As Double ] [, sourceX As Double ] [, sourceY As Double ] [, sourceWidth As Double ] [, sourceHeight As Double])
So the code should rather be
g.DrawPicture(Pic, 0, 0, g.width, g.height, a, 0, g.width, g.height)