General information
Category:
The Mere Mortals Framework
One of my favorite controls is the cIfcombobox. It's simplicity and elegance make it a favorite control among my users, too. The problem with it, though, is when you cancel out of adding a value "on the fly". Even if you cancel the buffer gets changed, and the bizobj asks you if you want to save the changes, even if nothing else has changed.
This is inconvenient if you don't want to cancel out of everything, but you do want to cancel adding a new value in the combobox.
Here's what I suggest:
In the lostfocus() event, if the user cancels use the setfldstate function to trick the bizobj that the field never changed. Simple!
*-- Add the new entry
lcID = DoForm(this.cFormName, this.DisplayValue)
IF !EMPTY(lcID)
this.Requery()
this.Value = lcID
ELSE
this.DisplayValue = ""
this.cSearchString = ""
*----------------------------------------------------
*-- Trick foxpro into thinking nothing has changed
*----------------------------------------------------
lcFieldName = JUSTEXT(This.controlsource)
lcAlias = JUSTSTEM(This.controlsource)
=SETFLDSTATE(lcFieldName , 3, lcAlias)
*----------------------------------------------------
RETURN .F.
ENDIF
ENDIF
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only