Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid columns controlSource
Message
De
15/07/2000 07:10:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/07/2000 21:46:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00392786
Message ID:
00392849
Vues:
10
>I have a form with a grid on it. I used the builder to populate the columns on the grid.
>
>The grid worked fine, but I was unable to find any properties on the grid that matched up specific columns to specific fields in the child table. I scratched my head and gave up trying to figure out how it worked...until...
>
>I needed to delete the first column. Now everything has shifted in a weird (and unusable) manner. I have tried manually setting the columns' controlSources, and have tried setting the controlSource in each textControl (or whatever control) in each column to the correct field in the child table, all to no avail.
>
>Do I have to rebuild my grid from scratch with the builder? Is deleting a column the big no-no?


It's really straightforward. You can delete - add columns to your taste and set their controlsources to either existing fields in any table or use calculated values (readonly). In a master-child tables situation you could first use the builder to set master fields. Say you had 4 fields from master and need 3 from child. Then click grid and set columncount property to 7. Edit grid to set columns 5-7 controlsources to read something like myChild.field1-myChild.field3.
You could even have a calculated column(s). First add a column by increasing the columncount then set controlsource. ie:
(myMaster.Price*myMaster.Quantity)
You don't need to set textbox controlsources because they inherit from column by default.

You could also choose to do all these in code (most probably in init of grid) which I find easier most of the time :

with this
.Recordsource = 'myMaster'
.Columncount = 5
with .Columns(1)
.Header1.Caption = 'My first field'
.Width = 100 && Some txtmetric, fontmetric could be used to get a good value
.Controlsource = 'myMaster.Field1'
endwith
*....
with .Columns(3)
.Header1.Caption = 'My third field'
.Width = 100
.Controlsource = 'myChild.Fieldn'
endwith
*....
with .Columns(5)
.Header1.Caption = 'OnStock' && 'My calculated field'
.Width = 20
.Controlsource = '(myMaster.StockCount>0)'
.AddObject('chkStock','CheckBox')
.CurrentControl = 'chkStock'
.Sparse = .f.
endwith
endwithCetin
Ç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
Répondre
Fil
Voir

Click here to load this message in the networking platform