Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ComboBox Replacements ?
Message
De
24/06/1998 12:01:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/06/1998 02:51:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00105046
Message ID:
00111248
Vues:
20
Snip...
Could you explain this in some more detail, as if I'm correct when weset the textbox controlsource to item.code, won't it display theitem.code on the form and not the item.name ?
Hi Sonali,
Here is a sample class code (it uses highligthed class from gridx.zip - files.classes section). Not perfect but works :
************
* 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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform