Why else can't a Listbox.Cell be assigned data

I have a problem assigning a value to a cell in a listbox.
The cells of the listbox were filled with a “¿”. The very first cell is then made editable (type 3).

HubWordList.EditCell(0,0) HubWordList.ActiveCell.SelectAll
If I edit the cell and type in the values I have no problems with changing the value of the first cell.

I also have a method (GiveUp) where I replace all of the “¿” with correct values and it works for every cell but the first cell.

For j = 0 to MD HubWordList.CellType(i, j) = Listbox.TypeNormal t = HubWordList.CellType(i, j) HubWordList.Cell(i, j) = RfrshWord(k) k = k+1 Next//For h = 0 to MD//modulus section

What else could be happening?

What is RfrshWord?

As documented, Listbox.Cell only accepts String.
http://documentation.xojo.com/index.php/ListBox.Cell

RfrshWord is String. Sorry for not including

[quote=396619:@Arthur Gabhart]… it works for every cell but the first cell.

For j = 0 to MD HubWordList.CellType(i, j) = Listbox.TypeNormal t = HubWordList.CellType(i, j) HubWordList.Cell(i, j) = RfrshWord(k) k = k+1 Next//For h = 0 to MD//modulus section
[/quote]

You mean the first cell of the first row, or the first cell of every row? And by not working for the first cell, do you mean it does not change at all and still has the “¿” shown?

A few things are not obvious from the limited code given:

  • Is variable k initialized to 0 ahead of this block?
  • Is the value of RfrshWord(0) something other than “¿” ?
  • Is variable i = 0 before this code block starts?

I’d probably add something like this ahead of k = k + 1, then add a breakpoint on that line and examine in the debugger:

  dim s as string = RfrshWord(k)

Then make sure variables i, j, k, and s have the values you expect.

Yes. That is what I mean.

I probably should have added that everything works properly. The values are all changed and/or initialized properly.
k is 0 ahead of the For statement.
The cell umm indexes are correct. I use the same for statement to fill and check values elsewhere.

Just in case I had some code wrong, I did a test and the cell’s value did it’s flash when it umm wasn’t changed.

If i = 0 And j =0 Then HubWordList.Cell(0, 0) = RfrshWord(0) End If

Forgot to add in the first part - the celltype is normal.

t = HubWordList.CellType(i, j)

t is an integer and the celltype was correctly changed.

Apparently I still have an ActiveCell at 0,0
So, I added this line with no change.

HubWordList.ActiveCell.SelLength = 0

Edit: I just tested this on my PC and it changes the text of 0,0
It’s now a Mac problem.

Further edit: If step through the code on a PC, it changes the cell 0,0 value, but if I’m not in the debugger it stays the same.

What happens when you add the line below:

HubWordList.CellType(0,0) = ListBox.TypeNormal

Thanks for the idea. Nothing different

Do you have a heading?
Did you try listbox.invalidate?
Isn’t your loop too long?

I wanted to ask previously, but forget: Is i starts at 0 ?

Also, add a breakpoint somewhere in your code and follow the application run (click in step) in the debugger and watch what happens.

Since I do not kow if i starts at 0 I am asking (above)…

Thanks Derk.
Heading? Not here.
Invalidate? Just tried. Nothing.
Too long? It’s a spelling exercise. So it’s long.

Thanks Emile. Yes i does start at 0.

I also tried adding a set the column type to normal and default.

Grumble. How do I stop editing a cell.

ClearFocus

Thanks Emile.

I HAD thought that was only for things like controls.

If you have CellFocus, then :wink:

If this does not works (ClearFocus), try Listbox1.ListIndex = -1.