Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox with free text
Message
From
21/08/2018 07:41:56
 
 
To
21/08/2018 06:41:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01661681
Message ID:
01661684
Views:
80
This message has been marked as the solution to the initial question of the thread.
>I wonder if there is a way to use a combobox that also allows free text entry? The list has different values from an array, but if I enter a text that is not found in the list it blanks out on Lostfocus.

Combobox allows free text entry, that's the idea behind the control.

Non-listed values are stored in the .DisplayValue property, not in .Value.
LOCAL Test AS FormWithACombobox

m.Test = CREATEOBJECT("FormWithACombobox")
m.Test.Show(1)

DEFINE CLASS FormWithAComboBox AS Form

	ADD OBJECT ACombo AS Combobox WITH Left = 10, Top = 10
	ADD OBJECT ATextField AS Textbox WITH Left = 10, Top= 40
	ADD OBJECT DisplayCurrentValue AS Label WITH Left = 10, Top = 70, Autosize = .T., Caption = "Combo values will be shown here"

	DIMENSION ComboValues(1)

	FUNCTION ACombo.Init

		ALINES(Thisform.ComboValues, "One, Two, Three, Four", 1, ",")
		This.RowSourceType = 5
		This.RowSource = "Thisform.ComboValues"

	ENDFUNC

	FUNCTION ACombo.Lostfocus
		Thisform.DisplayCurrentValue.Caption = TEXTMERGE("<<ALLTRIM(This.DisplayValue)>> (Value = '<<This.Value>>')")
	ENDFUNC

ENDDEFINE
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform