Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random List/Entered ComboBox items

Status
Not open for further replies.

TexTgr

Technical User
Nov 26, 2008
2
US
MS Virtual FoxPro V7.2, SP-2, Running on MS-XP Pro. SP-3 4 Dec 2k8
COMBO Box

Hi there, I am having a bit of trouble w/ the Base Class _Combo Box.

Overall situation:

I have a cluster of controls, Label Box, Text Box & Combo Box plus various Lines. These clusters are installed in a Container and SAVE AS Class and stored in a Class Library. These Containers are extracted and placed into a FORM (container). Think of a Doctor's office FORM for ordering tests, labs etc. Question/Answer style. Each Container w/ clustered Controls is selected according to the Section & Question requirements. Procedure used is the NEWOBJECT Function & WITH..ENDWITH Command. Must be 200 or so of the clusters on each page and 100 or so different configurations. Sort of like playing w/ Tinker Toys or Lincoln Logs. Got this far - appears to work great!

Now we must make entries for each answer (Combo) Box. Quoting from the HELP FILES and Programmers Guide we must:: "Accept input that can not be predetermined". Meaning, to me, that the operator may choose from a prepared assemblage of acceptable choices, size, color, material of construction or Enter Character data words and phrases. The acceptable db choices are moved into a RowSource
= ARRAY, RowSource Type = 5, Style = 0 DropDown Combo, DisplayCount = 6, Array named & sized in AddProperty, public one Diminsion Array[48]. Other nondefault PEM's are: ColumnCount = 1, ControlSource = (public variable), DropDown Event = User Procedure to move db selections to Array, GotFocus = User Procedure to read & set up names, InteractiveChange = User Procedure to implement MS Article
140652, also LostFocus, NumberofElements = 6.

First, I will interject my thoughts a/o preferances as to how I would like this to work. Select from list or Enter character data word/phrase and move result to variable (ControlSource), NO user entries are to be placed back into db. Observations: Entry window may not be Blank & User
may enter data. Must Entry window be Blank prior to user entries? Must individual characters be accumulated by User Procedure or does Combo Box handle - i.e. one Move w/ Lost Focus or ENTER. Entries, either Selections or User entered, show up first in Text, can't figure out the
progression of data from Text to Value & finally to ControlSource. What does REFRESH do, which Property supplies (Daddy of) Data to other properties?

I really need to discern which operation is directed by which operator, Data progression from Default Text entry window to which operator/operation and finally to my ControlSource. Can I or should I try Editing of Selected list entry or Clear the selection and Enter new
data?

TexTgr
 
Hi TextTgr,

I'll try to answer at least some of your points.

First, you ask if the "entry window" must be blank in order for the control to accept user entries. By "entry window", I assume you mean the editable portion of the combo. No, it doesn't need to be blank, although the interface might be more obvious to the user if it is.

I don't see why you are setting the ControlSource to point to a public variable. What you need to do is to write code in the Valid event to determine (i) if the user typed a new value or picked an existing one, and (ii) what new value they typed or existing value they picked.

To do that, check the Value and DisplayValue properties. If Value is empty, the user typed a new value. DisplayValue contains whatever the user typed. If Value is not empty, then it contains the item that the user selected from the list. If the list has more than one column, Value contains the value from the bound column (as determined by the BoundTo property), while DisplayValue contains the value from column 1.

Once you know the value, you can go ahead and write it to the database or do whatever else you want to do with it.

Refresh won't change anything. If you update the underlying table and want the update to show in the combo, call the combo's Requery.

I haven't answered all your points, but I hope this will get you a bit further forward.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thread #1254-1517862 15 Dec 2K8
Subject: COMBO Box & "Accept input that can not be predetermined"

Thanks to Mike for his prompt reply. And Mike ask for a few qualifying points. I will try to answer:
+ The 'entry window' phrase refers to the box's data window, useful for observing SELECTED List item or user entered values.
+ CONTROLSOURCE = (variable) suites my application best, provides security between forms & stays away from the usual multiple user conflicts etc.
+ The similarity of Prompt/Answer quantities & mixture of like minded subjects would put the Maximums for VFP's db at jeopardy, not to mention a design nightmare. My thoughts here are to use the dbs as READ ONLY Shared, for maximun availibity. One form's data would be stored in one file, with pre-determined folder & file names.
+ The VALUE and DISPLAYVALUE properrties are also assessable from the INTERACTIVECHANGE event. The difference between the INTERACTIVE and VALID events escapes this weary programmer, but I assume from the titles that it has to do with the positioning in the data flow path.

Back to the question:
+ The VALUE property acts as advertised and responds to EMPTY(). If VALUE is not empty, then the value observed is the index to the array of ROWSOURCE and selection.
+ Any entered value, test gibberish, appears in the TEXT property Only!
+ Yes, I can write an entered/typed value to my CONTROLSOURCE variable. This value disappears w/ LOSTFOCUS. - As observed!
+ If an item is chosen from the array, then it appears in the variable without any code interference (or automatically as a result of some other helping hand). The chosen value overwrites present displayed value.
+ If entering data, it is best to start w/ a clean slate, for one reason there are less keystrokes. Otherwise, one must write code to erase the existing value, whole or partial. There is NO consistant overwrite or replace as in edit. Since the window is sized for a maximum of 25 characters, re-entering some chars is a small price.
+ Vendor provided documentation hints that REQUERY() was intended as a beefed up CONTINUE for the Select command.
+ Entered data appears to require an 'Enter' keystroke in order to activate the VALID event, signaling that a value has been entered, vs each character in the KEYPRESS or INTERACTIVECHANGE event.
+ MS Support's Knowledge Base # 140652 uses the offices of INTERACTIVECHANGE to, "... capture input in a compo box ...." I used this as my starting point.

Desires:
+ I would like for the two parts of a COMBO box, Text & List, to perform as partners, and have the equivalent result.
+ Choosing a value item from the Drop-Down's yields reasonable results. Once the chosen value, selected or entered, has been captured, the path to CONTROLSOURCE field or variable should be identical or very similar. IF..ELSE..ENDIF territory.
+ May have answered my own questions and still can't C it!

Some person out there must have trod this path before & has an answer - even if it is, 'Can't be done.'.

Thanks, TexTgr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top