Export Listbox Row into a file

At the origin, I wanted to ask for help to end the code (far below). Then, I had the idea to use a TextOutputStream to save the Row contents. I decided to share the code when it was not 100% functional.

It works now, so I modified the core of the text and share the code (still far below).

I want to export (at first) a Row from a Listbox (later the selected Rows) into a text file. I have the base code (large, read below it works now).

The main idea was to create an image of the Row to export to disk and put that image into the Drag ( la drag an image). Get an eye in the shared code (read below).

I test it on macOS, but it have to be XPlatform.

The code is in disorder, have some comments, may be confused/confusing, etc. but it have nearly all I want into it. (I have to add a search for the selected Rows if more than one, and put the text from all Rows in the file).

Its late in the evening here, so I do not know (now) if the code below can be optimized (Try End Try Emile !), if code lines can be removed, and so on.

So, if you have comments, optimisations, etc.: feel free to report them.

The code is in the Listbox.MouseDown Event:

Dim Row_Width As Integer
Dim Row_Height As Integer
Dim Row_DI As DragItem
Dim Row_Pict As New Picture(Me.Width,Me.RowHeight)
Dim Text_Font As String
Dim Text_Size As Integer
Dim row,column As Integer
Dim TextFI As FolderItem
Dim TextTOS As TextOutputStream
Dim SQLDate As New Date
Dim SuffixName As String

// Get the Row and Column
row = Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)
column = Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top)

// Get some Listbox Properties
Text_Font = Me.TextFont
Text_Size = Me.TextSize

// Get the Row Width and Row Height
Row_Width = Me.Width
Row_Height = Me.RowHeight

// Set the Pen Size
Row_Pict.Graphics.PenHeight = 2
Row_Pict.Graphics.PenWidth = 2

// and draw a Rectangle around the Picture
Row_Pict.Graphics.DrawRect 0,0, Row_Width, Row_Height

// Draw a sample String: Me.Cell(0)
Row_Pict.Graphics.Forecolor = RGB(0,0,0)
Row_Pict.Graphics.TextFont = Text_Font
Row_Pict.Graphics.TextSize = Text_Size
Row_Pict.Graphics.DrawString Me.Cell(Row,Column),10,10

// Get a New DragItem
Row_DI = New DragItem(Self, X, Y, Row_Width, Row_Height)

// To make the file name unique
SuffixName = ReplaceAll(SQLDate.SQLDateTime,":","-")

// Save the image into Temporary
TextFI = SpecialFolder.Temporary.Child("Row - " + SuffixName + “.txt”)
TextTOS = TextOutputStream.Create(TextFI)
TextTOS.WriteLine LB.Cell(Row,-1)

// Do the Drag
Row_DI.DragPicture = Row_Pict
Row_DI.FolderItem = TextFI

Forget everything about drag outside a Window (in a Xojo App) in Linux.
It does not work.

Drag ends on the window borders

So sad :frowning: