Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controlsource of combo
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00034532
Message ID:
00034797
Vues:
48
>>>>>>>>>>I have a combo, .Style = 0-dropdown combo, .RowSourceType = 1-Value, Rowsource = TBD,N/A,VARIOUS, ControlSource = mytable.myfield. I thought that .Style = 0 meant that I could enter anything in the control, but it's not showing what I type, unless I select or type one of the three values in Rowsource. Since, for testing purposes, I have left in an old textbox with the same controlsource, I can see that values other than these three are not being saved to the table. What's going on?
>>>>>>>>>
>>>>>>>>>I guess, the problem originated from ControlSource. Personally, I don't use this property at all. Basically, combo will work this way:
>>>>>>>>>Combo.Lostfocus event:
>>>>>>>>>if this.dispalyvaluethis.value
>>>>>>>>>This.additem(this.displayvalue)
>>>>>>>>>endif
>>>>>>>>>Use Value property when you "Save" the record to fill appropriate field.
>>>>>>>>
>>>>>>>>I wasn't sure what "if this.dispalyvaluethis.value" meant.
>>>>>>>
>>>>>>>Yes, I just forgot that this is HTML and missed the symbol. Sorry, about this.
>>>>>>>
>>>>>>> Perhaps "if this.displayvalue # this.value". I didn't want to add items to my combobox, and I wasn't sure how .displayvalue was used here. My combo has only one column. I did try removing the .ControlSource and putting a REPLACE myfield WITH THISFORM.combo.Value. Now my typed value remains visible in the combo, but is still not added to the table.
>>>>>>>
>>>>>>>If you want to use existing items only, then set Style=2. If you want to type something else, you must add items to RowSource.
>>>>>>
>>>>>>I want this control to display the value of the field during navigation, and offer a few choices: TBD, N/A, and VARIOUS when adding and editing. It sounds as if the dropdown combo with style=0 is useless, because of the requirement to always use .AddItem, which will not be possible when just navigating the table. Maybe I should superimpose a textbox and make the combo visible only in edit mode.
>>>>>
>>>>>No, drop-down box is ehough itself. BTW, you can also use simple textbox with Format="M" and inputmask="TBD,N/A,VARIOUS"
>>>>>>
>>>>>>By the way, when I actually looked at the documentation, I noticed that it says to put the .AddItem in the .Valid, not .LostFocus. But I found that when I entered a value and then clicked on a nearby editbox, .Valid never fired, and the value was wiped out. I found no problem when I put the code in .LostFocus, as you said to do. It sounds as if you know more than the guy who wrote the book.
>>>>>
>>>>>Thanks.
>>>>
>>>>I don't want preset choices. I just want to offer some choices during adding and editing. In a majority of cases, those choices will not be used. But they are used often enough (5-10%) to make them worth offering. How do you make a combobox display a field value during simple navigation when the field value is usually not one of the choices?
>>>
>>>The simplest way is just to add one more item (SPACE(1)) to combo and use it in 90% cases.
>>
>>I don't see how that helps. The 90% of cases are not SPACE(1). They are various numbers, in character format.
>
>Oh. Now I got it. Here you really better use textbox+combobox (or list). You can use drag-and-drop functionality to 'bring' items from list to textbox by user interactions.

I didn't like the idea of dragging and dropping, so I made a textbox over the top of the combobox, making the combo.visible = .T. when editing, making the textbox.visible = .T. when not. I put an additem(THIS.DisplayValue) in the lostfocus of the combo, but I find that, contrary to what I said before, it is possible to lose the value before the lostfocus fires and does the additem(), particularly if I type a value and then click my Save button. Moving it to the .Valid didn't help. This is really annoying. It makes the drop-down combo, .Style=0, useless. Is there something else I can do to make it reliable? This seems like a basic problem. Surely I'm missing something?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform