Listbox textarea cell - carriage returns..?

Hi all,

I am trying to get a given cell in a listbox to allow me to input text with carriage returns (pressing the enter key). I have stopped it from ending the editing, but I can’t seem to figure out how to actually insert an EndOfLine into a textarea of an editable listbox cell.

My most recent attempt:

select case key
  case chr(13)
    if column = 2 then
      Dim s As String = me.Cell(row,column) + EndOfLine
      me.Cell(row,column) = s
      return True
    end if
    
  end Select
  
  Return False

Does prevent the cell from stopping editing, but it’s not inserting an EOL into the cell value (I’m either doing it wrong, or doing it in the wrong place). I know carriage returns will go into the field (like if I type several lines with carriage returns in a text editor and copy that text and past it into the cell) - but I’d really like to be able to key it in so I wouldn’t have to create the block of text in another app to copy and paste it into my cell.

You may want to have a look there : https://forum.xojo.com/1410-multiline-text-in-listboxes

Hi,

I had actually already seen that post, it didn’t cover what I was looking for - where as that was more of how can you display multiple lines in a listbox, my question is the ability to press enter and have it properly store the carriage return.

As far as I know the TextArea feature of EditCell does not provide any of the TextArea control features beyond cursor. Pressing Return exits the editable mode. Using Keydown can inhibit that but yet, since the editable field has none of the select features of the TeaxtArea, and besides there is no way to access that Text property during that phase, it looks impossible.

The best workaround I can think of is to display a real TextArea of the same height as RowHeight which will have all the features of a TextArea, and make it so it updates the Cell() content. I verified the cell() can contain endofLines. You will need to do something in CellTextPaint to display it, though.

Five years too late, but I figured how to do this:

In the CellKeyDown event add this to insert a carriage return using Shift + Return.
Use the Return key to end editing.

[code]//Shift + return key - inserts end of line
if Keyboard.AsyncKeyDown(&h24) = true and Keyboard.AsyncShiftKey = true then
me.ActiveTextControl.SelectedText = EndOfLine
return True
end if

//return key
if Keyboard.AsyncKeyDown(&h24) = true then return False
[/code]