Changing text in Listbox cell from contextual menu

Well, here I am in a quandary again. I know I’m either doing something wrong or missing something.

What I’m trying to do is change the contents of a listbox cell when the user selects something from the contextual menu put up on a right-click from that column. The cell is editable so the user can either type into the cell or select a menuItem to replace the contents of the cell. (What I really want is a combobox celltype but I haven’t got one so this will have to do for now.) Anyway, the contextual menu is being built and pops up correctly. But when the item is selected, the cell’s contents aren’t being updated.

Ok, when the user enters the cell the contents are selected and editing is enabled. Typing into the cell works fine. The only problem is feeding the text from the contextual menu to the cell. Here’s the code from the contextual menu action event:

[code] Dim i As Integer
Dim str As String

i = Me.ListIndex
Select Case hititem.Text
Case “Remove Item” // This case works fine.
me.RemoveRow(i)
Else
str = hititem.Text // I realize this is unnecessary but I have it for debug purposes
me.Cell(i, 4) = str // Column 4 is the column in question here.
me.Refresh
End Select
[/code]

So, what am I missing?

Does System.Debuglog str actually show what you expect ?

If the user is currently editing the cell (it has focus when you do this), you must also change ActiveCell.Text. Otherwise, the value of ActiveCell.Text will be plugged into the cell when it loses focus, overwriting your change.

Duh! Of course. Thanks, Tim. I knew I was overlooking something.