Multiline text in Listboxes

I have been using a listbox with multiline text in RealStudio for a while, but its challenge has been that whilst you can display text in a multiline format, eg using the cellTextPaint event, you weren’t able to edit cleanly in a multiline format since the cell text is a textField, and the text goes beyond the edge of the field, so you have to scroll back and forth horizontally.

Now along comes Xojo and I note a listbox.typeEditableTextArea has been added to the column types. Hurray I thought, I’ll be able to edit multiline text in a nice wrapping textArea. And you can, its great. But you can not longer display that text in a wrapping format. It now all goes off the end after the three dots…

Not sure if this is a bug or an undocumented feature, but does anyone have a solution. Effectively I’d like to turn on the multiline property within the listbox text area so that I can both view and edit text in a multiline wrapping edit box.

Jim

Use the StyleGrid from Einhugur? It can do variable row heights and using one of the OpenSource subclasses you can use a true TextArea.

[quote=9934:@James Pitchford]I have been using a listbox with multiline text in RealStudio for a while, but its challenge has been that whilst you can display text in a multiline format, eg using the cellTextPaint event, you weren’t able to edit cleanly in a multiline format since the cell text is a textField, and the text goes beyond the edge of the field, so you have to scroll back and forth horizontally.

Now along comes Xojo and I note a listbox.typeEditableTextArea has been added to the column types. Hurray I thought, I’ll be able to edit multiline text in a nice wrapping textArea. And you can, its great. But you can not longer display that text in a wrapping format. It now all goes off the end after the three dots…

Not sure if this is a bug or an undocumented feature, but does anyone have a solution. Effectively I’d like to turn on the multiline property within the listbox text area so that I can both view and edit text in a multiline wrapping edit box.

Jim[/quote]

I don’t see the problem… The Just keep drawing wrapped text in CellTextPaint as you did before… once the overlayed text area disappears celltextpaint is called to repaint the cell…

I do that and a lot more in my MergedCell listbox…
http://mysite.verizon.net/vzezdg8x/id5.html

The problem is that the EditCell call appears to only give you a TextField to edit NOT a TextArea.

Hmmm I’m pretty sure the listbox USED to use a textarea for editing if you specified it (at least when specified by cell)…

In any case, with some effort, it is possible to move an external textArea over a cell for editing… That is what did in my listbox subclass to handle editing merged cells.

  • karen

I’d love to see an example of that, Karen. Even if just the end compiled effect the user experiences.

This code In ListBox.CellClick seems to indicate that the cell is a TextArea:

[code]
Me.CellType(row, column) = ListBox.TypeEditableTextArea
Me.EditCell(row, column)

If Me.ActiveCell IsA TextArea Then
TextArea(Me.ActiveCell).MultiLine = True
Break
End If[/code]

To see it in action you could download the encrypted classes used in a demo that only run in the IDE at:

http://mysite.verizon.net/vzezdg8x/id5.html

So, by default is Impossible to resize a row in Listbox?

I write here, in order to use the same thread and not open a new one.

I have a big text in a cell, but I dont want to have a big column, I need a fixed size column.
At this point I’m Ok.

That I need to know is that It factible to when text reach the limit of column size then write a new line or resize the row width.

Thanks

You can change the size of all of them, but not just one.
http://documentation.xojo.com/index.php/ListBox.DefaultRowHeight

As mentioned above listbox row height normally can not be changed only for single row. However it is possible to sort of merge cells to effectively make a row a multiple of the set row height. That is what my listbox subclass does:

See:
http://www.katkosoft.com/Mergeable%20Listbox%20Page/MergeableCellListbox.html

  • Karen

thanks for the keys to the solution.
in my viewpoint, you have to use a combination of replacelineending and encoding so that textarea and files work together.
regards

Hey guys, so I’ve read this thread and tried a few things but I’m still not getting anywhere …

All I want is to be able to add a string to a listbox cell, where the string has more than one line of text.

I don’t even want to edit it, just display it in a multiline format.

Simply put:

Dim CR as String = EndOfLine

MyList.Cell(0,0) = "String 1" + CR + "String 2"

Possible? How?

Thanks in advance.

Draw the text yourself in CellTextPaint. Make sure the row height is large enough.

Thanks Tim,

Any chance you have some sample code of what that looks like?

Thanks, Ken.

Ken, you can try something like this:

Dim arr() As String = Split(Me.Cell(row, column), EndOfLine) For i As Integer = 0 To ubound(arr) g.DrawString(arr(i), x, y - g.TextHeight + i * g.TextHeight) Next Return True

This code is for 3 line cell, first line will write at top, second line at middle and third line at bottom.

Note: this is not the best code and should be changed to your needs.

You’re a legend Alberto … many, many thanks mate.

Is this still supported ? Don’t see it on the EH website anymore.

no, it was a realstudio-carbon-os9 product.
https://einhugur.com/Html/StyleGridInfo.html
https://forum.xojo.com/conversation/post/75395

Yeah, that answer was from 2013 and StyleGrid still worked. I miss StyleGrid - it had some really nice features.