Detecting Programmatically Changed Text in a Listbox Cell

I’m well aware of the “CellTextChanged” event for listboxes. However, that event does NOT fire when you programmatically change the text contents of a listbox cell. There’s several threads on the forum here that relate to this issue, but all of them that I found were at least several years old and none of them had a solution. I even thought I could be clever and use a combination CellGotFocus and CellLostFocus to do what I need (determine if the contents of a cell changed) but those events don’t fire either when the cell is not set up to be “editable” (which in my case, they are not editable).

Has anybody found a way around this?

Thanks in advance for your consideration!

So how is it you don’t know WHEN the text is changed?
At some point don’t you have code similar to

listbox1.cell(row,col)="new data"

if so, just call your “textchanged” code at that point

subclass listbox and override listbox1.cell(row,col)
then you can tell

[quote=470789:@Dave S]So how is it you don’t know WHEN the text is changed?
At some point don’t you have code similar to

listbox1.cell(row,col)=“new data”
if so, just call your “textchanged” code at that point[/quote]
Thanks for the response, Dave. Although it’s not quite that simple in my case, your input did redirect my focus to something I hadn’t considered but does workaround the issue. The listbox cell in question is being fed data from a textfield where the user makes changes. Upon the textfield losing focus, it programmatically replaces the listbox cell contents. With your idea in mind, I can capture the existing listbox cell content upon entering the textfield with the textfield’s GotFocus event and compare that to the textfield’s text when the user leaves the textfield with the textfield’s LostFocus event (which is when the programmatic change to the listbox cell occurs) to see if there was any change in the content.

Thanks for the idea!

[quote=470790:@Norman Palardy]subclass listbox and override listbox1.cell(row,col)
then you can tell[/quote]
Thanks for taking the time to look at this and respond, Norman. I had a feeling that subclassing was going to be an answer, but I have minimal experience with it and the program I’m working on must be done by Monday in order to demo it at a customer’s site. I’m just not sure how much time (study?) it would take me to do what I want and I’m running out of time as it is. You have, however, convinced me that it’s the long term solution to my need (and others I’ll face in the future, I’m sure). So, when I get back next week from my customer demo, I’m going to bite the bullet and sit down and learn what I need to in order to be able to do it. It’s fair to say that that’s one “education” that’s long overdue.


you will find subclassing in Xojo very intuitive. IDE file menu Inset -> Class, name it what you want then select the Super class (Listbox) and you will see your newly created class icon in the IDE change to that of a listbox.

For overriding here is a good forum post Over Riding

Thanks so much, Brian! That forum post answers a number of the questions I had. I gave a quick look through the Xojo examples provided with the installation but didn’t see anything about the topic. I know there’s a couple of examples in the User’s Guide but it’s quite limited with little explanation. If you’re aware of any other sources of subclassing educational material (e.g., “Subclassing for the Subclassing Challenged” or something like that :smiley: ), I’d be most grateful if you passed it on to me.

Here you go Don, just a quick example, I hope it helps you, g’luck on Monday!