Word wrap in ListBox?

  1. 6 weeks ago

    Is there a way to wrap words in a ListBox cell when the text is too long to be seen in its entirety, automatically deepening the row to fit the wrapped text?

  2. Bob K

    Feb 15 Pre-Release Testers, Xojo Pro Kansas City

    RowHeight is variable, but it affects ALL rows. Not just a single row.

    You can do your own text drawing using the CellTextDraw event. So you can do pretty much whatever you have the heart to do.

  3. @Bob K You can do your own text drawing using the CellTextDraw event.

    Thanks for the reply. Yes, I'm aware of CellTextDraw, I was just hoping for a simpler method :)

  4. Michel B

    Feb 16 Pre-Release Testers, Xojo Pro

    You can use CellTextDraw only when the text is too long.

    Then it becomes very simple :

    Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) Handles CellTextPaint as Boolean
      if g.stringwidth(me.cell(row,column)) > g.width then
        g.drawstring(me.cell(row,column), 2, g.height*0.4, g.width-3)
        return true
      end if
    End Function

    Make sure to have enough DefaultRowHeight for text to wrap.

  5. Bob K

    Feb 16 Pre-Release Testers, Xojo Pro Kansas City

    It's possible there is a 3rd party solution that does this automatically. I don't know of any but perhaps someone else knows.

  6. Michel B

    Feb 16 Pre-Release Testers, Xojo Pro
    Edited 6 weeks ago by Michel B

    Karen's Mergeable Cell Listbox does it (and many other things)
    http://katkosoft.com/Mergeable%20Listbox%20Page/MergeableCellListbox.html

  7. Thank you all for your replies.

or Sign Up to reply!