Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CRASH: Combobox into a Sparse=.F. column
Message
From
21/01/2005 13:20:45
Walter Meester
HoogkarspelNetherlands
 
 
To
21/01/2005 09:35:19
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00978487
Message ID:
00979364
Views:
20
Hi Marcia,

>One that comes in mind is that when you bind the value to a numeric column and the control is not bound to anything (Controlsource = ""), the Value, sometimes is numeric, sometimes caracter. The other way arround also seems to be true. When it is bound to a column that contains character, but a numeric value, it sometimes is converted into numeric and sometimes to character.

>I do not understand what you are trying to say here. Do you mean that the BoundColumn comes from a data source that is numeric but the combos's ControlSource is empty that the data type of the value changes? If so, I am sure that you know that the default value for the Value property is an empty string (i.e., character data). As you know, the value of a combo or list box is taken from the column of its internal list that is specified by its BoundColumn. Now, if the combo's BoundColumn comes from numeric data, it seems perfectly obvious to me that you must initialize the control's Value property to zero in the property sheet in order for things to be consistent.

No matter with what I initialize the value, it sometimes changes. It changes from character to numeric or the other way arround. I've found that initializing it to character is the most reliable, however occasionally I find instances where it 'randomly' converts to numeric again. Now this is AFAIK only happening when you don't specify a controlsource.

>While it is indeed true that the combo stores the data in its internal list as character data regardless of its original data type, setting BoundTo to true will automatically handle the conversion of the combo's value to the numeric data type.

I know, but there seems to be a leak in some circumstance. It certainly happened to me multiple times when when I did not specify a controlsource.

>If this is what you are talking about, this is not a combo box "issue". IMHO, this just comes down to understanding how the comtrol works < s >.

Believe, me I know just as much as you do know about comboboxes (and I do have a copy of a few of your books) and I do use them extensively in various situations. And therefore I do know there is a bug when it comes to keeping the same datatype in the combobox value property when the control is not bound to a property or field.

>I've dealt with this issue more than once since VFP5. I now always set the controlsource to a character property to avoid the issue. Anyways, this is one bug that really irritates me.

>And I almost always bind my combo boxes to an integer foreign key field. I bind to character data less than 1% of the time. I have never seen the bug that you are decribing, whether my combo's are bound to numeric data or left unbound.

Well, I do bind them a lot to integer fields also, and you're right, then there is no problem at all. With binding them to a character field, no problem also. However this issue arises when not binding them at all and using the value property to get their status. For exampe a selection combobox at a form to filter a grid. If you don't bind it to a property on the form, you might experience this problem.

>Why can't the VFP team solve the situation in such manner that if the sparse property is set to .F. the combox' downarrow is not displayed in every row ?? sure a workarround does exists (And I use them a lot), but it still is a kludge that should not neccesary at all.

>All you have to do is set the column's ControlSource up like so:
>
>
>( IIF( SEEK( < RecordSource.ForeignKeyField >, '< LookupTable >', '< LookupIndexTag' ), LookupTable.Description, '' ) )
>
>And set up your combo with any RowSourceType but 2-Alias or 6-Fields and populate it with the data from the lookup table. You can then leave the column's SParse property set at its default value (true). I do not understand why you think it is a kludge.

I knew, you were comming with this example (that is why I explicitly mentioned SEEK in the previous message). That is great if the combobox is populated from a cursor. However most of my comboboxes are populated from an array property on my combobox baseclass.

So I use views which have also the meaningfull value, which populates the column and the integer field which populates the integer field. When you change the combobox value, the comobobox class automatically writes the displayvalue in the character meaningfull field. However, it is still a kludge.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform