Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to set default value for combobox?
Message
 
 
À
11/10/2000 16:18:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00427909
Message ID:
00428089
Vues:
16
>>>>If you have a combobox, which is dropdown list, after you make your selection, how can you return to default (empty state)?
>>>>Suppose, you have a field in your main table, which may contain a coded value or could be empty. For this field you use a combobox (drop down list). Suppose, you choose something. How then could you return it back to empty state? Seems there is no way, unless you would code some event to do so, say, Right Click.
>>>
>>>You'd have to include an empty member of the row source.
>>>e.g.,
>>>
WITH thisform
>>>  DIMENSION .aRow(3)
>>>  .aRow[1] = ""
>>>  .aRow[2] = "hello"
>>>  .aRow[3] = "world"
>>>  .cboCombo.RowSourceType = 5
>>>  .cboCombo.RowSource = "thisform.aRow"
>>>  .cboCombo.Requery()
>>>
>>>** or
>>>  .cboCombo.RowSourceType = 1
>>>  .cboCombo.RowSource = ",hello,world"
>>>  .cboCombo.Requery()
>>>
>>>ENDWITH
>>
>>Trey,
>>
>>The RowSource for this combobox is a select statement and it selects from Lookups table, which don't have empty record. What should I do in this case?
>
>Add a UNION to the SELECT with empty values for the same fields in the SELECT.
>e.g.
>
SELECT cname, ccity, nage FROM people ;
>  UNION ;
> SELECT "" AS cname, "" AS ccity, 0 AS nage ;
>  FROM people ;
>  INTO CURSOR cuRowSource
>As long as the empty row select is the last select, then you shouldn't have the problems that would come up with field widths - like the typical ALLTRIM() problems where the first row returned has a shorter trimmed length than other records

Hi Trey,

Are you sure, there is no other solution, rather than use select with union (I thought the same, BTW)? The reason, I'm asking, is there are lots of comboboxes, which are used in our application. Does it mean, that we should re-define RowSource for all of them?

I was thinking about something like this in combobox.RightClick() method for our combobox class:
 this.displayvalue=''
 this.value='' && Basically these comboboxes have character value
Not sure, it it would work.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform