Freeze first column of a listbox

Hello All,

Is there a way to freeze a column in a listbox so that I can keep scrolling?
Ideally I want to freeze the first column of the listbox and be able to scroll “N” columns to the right.

Thanks.

With the standard listbox… no

however there are a few 3rd party controls available that extend the functions of the listbox,

Hi Dave,

Thanks for the reply.
Any suggestions?

Thanks.

Could you use a separate listbox? You might be able to set the scrollpostion to match the other in the CellBackgroundPaint event to keep them synchronized.

Draw column 0 yourself and it can be whatever you want. CellTextPaint conveniently provides the x and y to draw a string at.

This code assumes you want the cells of column 0 to stay top justified but can be modified to pull from an array or some offset position within column 0.

[code]Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean

if column = 0 then

dim r As integer = row - me.ScrollPosition

if me.Selected(row) then
  g.ForeColor = &cFFFFFF
else
  g.ForeColor = &c000000
end

g.DrawString me.Cell(r, 0), x, y

return true

end

End Function[/code]

edited to account for selected texted color being white.

Hi Will,

Thanks for that idea. I will have to play with that, it may work for me.

Craig