Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best approach for listbox on values
Message
From
12/07/2001 07:23:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
11/07/2001 23:03:42
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00529536
Message ID:
00529605
Views:
26
Michel,

I created a class cMultipleChoice, based on ComboBox. Perhaps you need something similar.
.BoundColumn = 2 && Value will be returned from second, invisible, column
.ColumnCount = 1 && only one visible column
.StatusBarText = "Select an option"
.Style = 2
Method .AddOption:
  lParameters lcText, lcValueSaved
  This.AddItem(lcText)
  This.ListItem(This.ListCount,2) = lcValueSaved
I populate the ComboBox in its Init(). Sample:
DoDefault()
This.AddOption("Terminado", "T")
This.AddOption("Intermedio", "I")
This.AddOption("Externo", "E")

The ComboBox is usually bound to a field; in the example, the user sees longer texts, but only a one-character code is saved to disk.

Hilmar.

>>>>>I am wondering what is the best approach to take when we have a listbox of type 1 - Value where we enter our own values in RowSourceType property. It's not like a listbox of type 3 - SQL where we can bound the control source to field on BoundColumn 2. Basically, what is the best approach to bound the control source when entering the values manually at the form designer level?
>>>>
>>>>Nothing should change here. It doesn't matter, what's the RowSourceType property for the combo.
>>>
>>>It matters as the values entered manually are not the values which goes in the table. In a listbox of type 3 - SQL, where we could have SELECT DESCRIPTION,PRIMARYKEY FROM PIVOT ORDER BY 1 INTO CURSOR TEMP, we can have a BoundColumn to 2. So, the PrimaryKey value will be saved.
>>>
>>>When entering the values manually, such as MyValue1,MyValue2 with a listbox of type 1 - Value, there is no direct approach of having an automatic relationship with the value we would save. For example, we have a full description 1 and a full description 2. But, we only save a small description 1 and a small description 2.
>>
>>Not sure, I understand your problem. I just made a quick test. I created a form with a combo with RowSource='AAAA;BBBB;CCCC' I put ControlSource as Towns.Town field and BoundColumn=1 (default). I ran the form, chose BBBB and exited. Then I checked Towns table and the value in the first record was BBBB.
>>
>>What is your problem?
>
>Yes, that works but it is not my situation. What I need is to save another value than the value showed in the listbox. That is the same way as if I would use a SQL as described in my original reply. So, basically, the values are entered manually but I need to save another value.
>
>One approach would be to create a cursor when entering the form and select from that cursor and use the SQL approach. But, I am wondering if there is something faster.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform