Hoped-for ComboBox event like "Linked cell changed"

If a spreadsheet cell is linked to a ComboBox any changes to the cell’s content are mirrored in the current text of the Control, and if the new text is occurring int the list of the Box even the selection is updated (if enabled). Nonetheless neither Text modified nor Item status changed are thrown.

Is there a way to make the control raise an event on Linked cell changed?

1 Like

(comment deleted)

Hello @Lupp,

Agree with your findings that modifying the linked cell and using an event in the list of the control (combo or list box) does not trigger an event.

Did a test by setting a listener on the linked cell and that worked for both cell and combo box changes. However the objective was to have this occur within the control.

Found by adding an XModifyListener to the Value Binding of the control (again combo or list box) that this would work.

Have added a sample. Linked cell is A1. Buttons are there to start/stop the listener.

LinkedCell.ods (10.6 KB)

(I obviously still don’t understand the discourse software.)
Thanks! Very intersting.
Would still prefer a
onTextModified thrown for any modification, and an
onTextEdited only thrown if the text was edited in place.
The control (or the form containing it) should be able to manage that.

The next way also works (under the conditions of the previous answer).

Global oModifyListener

Sub SetModifyListener()
    oModifyListener = createUnoListener("CellModify_","com.sun.star.util.XModifyListener")
    ThisComponent.Sheets(0).getCellByPosition(0,0).addModifyListener oModifyListener
End Sub

Sub CellModify_modified( oEvent )
    Msgbox "Modified " & oEvent.Source.AbsoluteName
End Sub

Sub CellModify_disposing()
    Msgbox "Disposing"
End Sub

Did note this in the second line of my response and agree. The issue here is that it is tied to the cell and not the control. If you change the bound cell within the control properties, the macro attached to the cell also needs to be changed.

You are absolutely right, I was not attentive enough.

Thanks for the enlightening alternative and comments.

XModifyListener scrupulously monitors cell changes while editing, recalculation of formulas, change as a result of macros.
The OnChange sheet event arises only as a result of editing, and not all user actions are processed (for example, Ctrl + D is not processed).