Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox refresh
Message
De
23/05/2005 05:52:27
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/05/2005 05:01:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Divers
Thread ID:
01016550
Message ID:
01016668
Vues:
9
>Help please!
>I added the following code in the listbox/init:
this.sorted=.t.
>use products again in 0
>select products
>scan
>	this.addlistitem(allt(products.product))
>endscan
>This.Enabled=.t.
Every thing is good but:
>I have a command button to open new form for adding new product.
>When I close the new form I don't see the new item in the list box of the main form only if I close the main form and reopen it.
>Thank for answer

Chaim,
It'd be easier if you use an SQL rowsource instead. ie:
this.RowSourceType = 3
this.RowSource = "select product,productID"+;
                 " from products"+;
                 " order by product"+;
                 " into cursor crsProducts"
This.ColumnCount = 1 && Show only product - but productID is accesible when you need it
This.Enabled=.t.
After adding a new item, all you need is:

thisform.myList.Requery()

You might even position to newly added item. ie: Newly added item has a PK of 123:
with thisform.myList
 .Requery()
 select crsProducts
 locate for pk = 123
 .ListIndex = iif( eof(), 0, recno())
endwith
To check what's selected you might (and IMHO you should) directly use underlying cursor:
lcProduct = crsProducts.Product
luPK = crsProducts.pk
This approach is much more intiutive then using addlistitem IMHO (just think what if you had thousands of records in products and/or while showing only product column you needed to know many fields of it). This is legal for a listbox:
this.RowSourceType = 3
this.RowSource = "select product as myProduct,*"+;
                 " from products"+;
                 " order by 1"+;
                 " into cursor crsProducts"
This.ColumnCount = 1 && Show only product name
You still show only product column but have access to any fields you might need.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform