Information générale
Titre:
Annoying grid column behavior
Hi,
I have a textbox class I use in the column of a display only grid to display a value based on the key value in the cursor field. Works like a champ EXCEPT for one annoying effect. If one clicks on that column, the column displays only the first character of the looked up description. IOW, everything looks great, the grid refreshes fine when the underlying data changes, etc., but if you should click on the column, all that columns displayed data vanishes except the first character. Does this ring any bells? I adapted some code Fabio Lunardon put up here for a similar purpose. The textbox definition is below.
Gary
DEFINE CLASS GridLookupTextbox AS ctextbox
*-- Column.sparse = .F.
*-- Column.bound = .F.
ControlSource = "m.this._Controlsource"
HIDDEN ControlSource
NullDisplay = "****************"
MyControlSource = "NULL"
_ControlSource = ''
BorderStyle = 0
DIMENSION aValues[1,2]
Width = 100
HIDDEN PROCEDURE _ControlSource_Access
*-- this.aValues is loaded when this is made the current control.
LOCAL nKeyValue
LOCAL cDescription
LOCAL nRow
cDescription = ''
nKeyValue = EVALUATE(m.this.MyControlSource)
IF ISNULL(nKeyValue) OR EMPTY(nKeyValue) OR ;
INT(VAL(TRANSFORM (nKeyValue))) = 0
cDescription = ''
ELSE
*-- If this control has an array with values...
IF TYPE('this.aValues[1]') = 'C'
*-- Scan the array associated with this control
*-- looking for the key value in column 2.
nRow = ASCAN(THIS.aValues, nKeyValue, 1, ALEN(THIS.aValues,1),2,8)
IF nRow > 0
cDescription = ALLTRIM(THIS.aValues[nRow,1])
ENDIF
ENDIF
ENDIF
*-- Return the description value
RETURN cDescription
ENDPROC
HIDDEN PROCEDURE _ControlSource_Assign
LPARAMETERS dValue
IF m.this.MyControlSource="M." && a variable or properties
STORE (m.dValue) TO (m.this.MyControlSource)
ELSE
REPLACE (m.this.MyControlSource) WITH (m.dValue)
ENDIF
ENDPROC
HIDDEN PROCEDURE MyControlSource_Assign
LPARAMETERS sControlSource
IF TYPE("m.sControlSource") == "C" && this skip bad source
THIS.MyControlSource = UPPER(m.sControlSource)
ENDIF
ENDPROC
ENDDEFINE
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement