DropEvent giving file location, not text

Hi, this is my code:

In Rectangle1 (area where text will be dropped) Open event, I have:

In its dropobj event, I have:

[quote]if obj.Folderitemavailable then
listbox1.addrow(obj.folderitem.name)
listbox1.RowTag(listbox1.LastIndex) = obj.FolderItem
End If[/quote]

But when I try it, I get the location of the folder rather than the contents inside, such as: “Documents/Untitled.txt”. What am I doing wrong?

Thanks!

with your code you can not get the contents, it gives you the folderitem name.

You must use TextInputStream to get the contents.

if obj.Folderitemavailable then Dim f As FolderItem = obj.Folderitem If f <> Nil Then If f.Exists Then // Be aware that TextInputStream.Open could raise an exception Dim t As TextInputStream Try t = TextInputStream.Open(f) t.Encoding = Encodings.UTF8 TextArea1.Text = t.ReadAll Catch e As IOException MsgBox("Error accessing file.") End Try t.Close End If End If End If

Thank you very much!!

I also have another question:

If the text in the file is too long, how can I tell it to move it to the next line once it has reached the width of the listbox?

Currently, it shows the text and has “…” for rest of it at the end in a single line.

Any help will be appreciated! Thanks.

The Listbox does not have multiline cells.

https://forum.xojo.com/1410-multiline-text-in-listboxes

[quote=375948:@Axel Schneider]The Listbox does not have multiline cells.

https://forum.xojo.com/1410-multiline-text-in-listboxes[/quote]

Hi Axel,

Is there a way I could add like 20 characters at a time? Then add the next 20 characters using addline? Would that work?

You can do it by using g.DrawString in ListBox.CellTextPaint

look at this from @Alberto De Poo
https://forum.xojo.com/45783-multiline-string-in-a-cell-listbox/0