ListBox New Feature

In a brand new project, add a ListBox to the window and name it LB:

  1. Add an Open Event into Window1,

  2. Copy / Paste the code below into the Window1.Open event:

[code] Dim LoopIdx As Integer
Dim LocRow As Integer

For LoopIdx = 0 To 3
LB.AddRow "Row " + Str(LoopIdx) + “, 0”
LocRow = LB.LastIndex
LB.Cell(LocRow,1) = "Row " + Str(LoopIdx) + “, 1”
LB.Cell(LocRow,2) = "Row " + Str(LoopIdx) + “, 2”
LB.Cell(LocRow,3) = "Row " + Str(LoopIdx) + “, 3”
Next

LB.Heading(-1) = “0” + Chr(9) + “1” + Chr(9) + “2” + Chr(9) + “3”[/code]

  1. Select the ListBox and add it a DoubleCLick Event, then Copy / Paste the code below into Window1.LB.DoubleCLick:

[code] Dim row,column as Integer
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)

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

Run and click in the right part of the ListBox to see what I reported earlier.

Example code:
Example project (5KB)

NOTA: I was not able to replicate the Return (in the Open Button of the Open file dialog) “pass thru” to the ListBox Cell 0,0 in edit mode.
You may or may not hear beeps using that example.

So, I added the compiled (Cocoa) application with a Text file so you will hear those beeps and see what the project allows you to do.
Do not use the Utilities Menus, they belongs to something else.

Generated application of the original project (where I originally have found that new feature):
The working application, 1.25MB

At Import time, if you press the Return key (to activate the Open button), you can see what I called “the Return passing thru”: one Return key press for two functions: press theOpen button and enter in the Edit mode for the ListBox Cell(0,0)…

In the archive, there is a text file. Use Import to load it and watch how the things work (or not). The red lines… are in red because there is nothing in Column 0 (either I do not found this story printed in a magazine or the story were not printed in French): it is a help to find missings.

Every column is resizeable, you can select one or more Rows (to copy it/them), you can move (drag) one or many Rows up or down (even non consecutive Rows), etc.

The two buttons in the ToolBar does not works too.

I took that skeleton project and improve it in a different way than the one I started with.

The projects have been created and modified using Xojo 2013 Release 4.1.
Xojo 2013 Release 4.1 runs on a MacBook Pro using OS X 10.8.5.

Again: you still calculate your columns wrong. Wrap the cell edit part like that:

If column < Me.ColumnCount Then
  Me.CellType(row,column)=ListBox.TypeEditable
  Me.EditCell(row,column)
End

Without that, you make the “free space”-column on the right editable. This is not a framework fault - this column (which is not included in ColumnCount) needs to exist, so you can draw the background in the CellBackgroundPaint event.

Or better: set the window width to display only the available column width: nothing to click on will be displayed. *

I compute nothing. I only copy / paste code from the docs ListBox :

Determining which cell was double-clicked:

Dim row,column as Integer 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) ' MsgBox "You double-clicked in cell "+Str(row)+", "+Str(column)

Making a Cell Editable:

Me.CellType(row,column)=ListBox.TypeEditable Me.EditCell(row,column)

  • Even if this suggestion is correct, this does not remove the fact that we are able to click on something that looks like a Cell but is not. And the data you put in that faked Column (Cell) is lost when you leave that non existant Cell.

BTW: I read back the Making a Cell Editable paragraph and move that code into the CellClick Event with the same success (trouble).

I added the If line like you suggest and yes, you cannot modify this Cell any more.

I still stand with my claim: something wrong is there and I put my feet on.

BTW: Eli, did you tried the application ?

To import the text file, I use three TextInputStream.ReadLine to load service data (the heading strings, the columnwidths and two defined colours) and one ReadAll to read all the text (LB.Cell(-1,-1) = ImportTIS.ReadAll.

Check the text file to have a better idea.

[quote]Even if this suggestion is correct, this does not remove the fact that we are able to click on something that looks like a Cell but is not. [/quote] That is because you make the column editable - it is your mistake. Exclude this “fill-up”-column like I suggested.