************ * SourceAlias and SourceField are typically LookupAlias and LookupField * TargetAlias and targetfield are "itemcode"s alias and field * This one simply pokes sourcealias's recno as itemcode - integer - * to target alias.field **************************************************************** *-- Class: GridCombo (c:\temp\test.vcx) *-- ParentClass: container *-- BaseClass: container * DEFINE CLASS GridCombo AS container Width = 312 Height = 245 Name = "GridCombo" targetalias = .F. targetfield = .F. sourcealias = .F. sourcefield = .F. ADD OBJECT txtdescription AS textbox WITH ; Height = 23, ; Left = 45, ; SelectOnEntry = .T., ; TabIndex = 1, ; Top = 0, ; Width = 267, ; Name = "txtDescription" ADD OBJECT lbldescription AS label WITH ; Caption = "Search", ; Height = 17, ; Left = 3, ; Top = 3, ; Width = 42, ; TabIndex = 3, ; Name = "lblDescription" ADD OBJECT highlighted1 AS highlighted WITH ; DeleteMark = .F., ; Height = 220, ; Left = 3, ; RecordMark = .F., ; Top = 25, ; Width = 309, ; Name = "Highlighted1" PROCEDURE Init with this if eval(.TargetAlias+"."+.TargetField) # 0 goto eval(.TargetAlias+"."+.TargetField) in (.SourceAlias) .txtDescription.value = eval(.SourceAlias+"."+.SourceField) .highlighted1.recchange() endif with .highlighted1 .readonly = .t. .setall("Backcolor",.cCurRecBackColor,"Textbox") .setall("Forecolor",.cCurRecForeColor,"Textbox") .setall("SelectedBackcolor",.cCurRecBackColor,"Textbox") .setall("SelectedForecolor",.cCurRecForeColor,"Textbox") endwith endwith ENDPROC PROCEDURE txtdescription.InteractiveChange with this cPos = .selstart if lastkey() = 127 && Backspace cPos = max(cPos - 1,0) .value = iif(cPos= 0,"",substr(.value,1,cPos)) endif =seek(trim(.value),.Parent.SourceAlias,.Parent.SourceField) .value = eval(.Parent.SourceAlias+"."+.Parent.SourceField) .selstart = cPos .sellength = len(.value) - cPos .Parent.Highlighted1.recchange() replace (.Parent.TargetField) with ; iif(recno(.Parent.SourceAlias)<=reccount(.Parent.SourceAlias),; recno(.Parent.SourceAlias),0) ; in (.Parent.TargetAlias) endwith thisform.refresh ENDPROC PROCEDURE highlighted1.AfterRowColChange LPARAMETERS nColIndex dodefault() with this .parent.txtDescription.value = eval(.Parent.SourceAlias+"."+.Parent.SourceField) replace (.Parent.TargetField) with ; iif(recno(.Parent.SourceAlias)<=reccount(.Parent.SourceAlias),; recno(.Parent.SourceAlias),0) ; in (.Parent.TargetAlias) endwith thisform.refresh ENDPROC ENDDEFINE * *-- EndDefine: GridCombo **************************************************Cetin