Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SETALL method for columns in a grid
Message
De
31/01/2005 16:45:25
 
 
À
31/01/2005 12:03:06
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
00982234
Message ID:
00982467
Vues:
39
Hi Nancy.

PMFJI. If you use a list-style combobox in a grid, you'll need to set the control's enabled = .f. (or the column) since readonly doesn't apply to these.

I just LOVE that feature. I use it all the time - and, as a matter of fact, even wrote about this in Chapter 1 of MegaFox: 1002 Things You Wanted to Know About Extending VFP

To use the cboGrdDropdown class in a form, just drop it into the desired grid column and make it the column’s CurrentControl. In our example, the combo is bound to the iClientFK field in the grid’s RecordSource. Notice that we did not merely use a RowSourceType of 6-fields for our drop down list and populate its RowSource as Clients.cCompany, iClientPK. There is a very good reason for this. If we used a RowSourceType of 2-alias or 6-fields for our combo, it would be blank when it got focus. This appears to be a bug that only occurs when you use a combo in a grid in this fashion, binding it to a foreign key value in the underlying data while displaying the descriptive text from a lookup table. Fortunately, with nine RowSourceTypes to choose from, we are able to work around this gotcha! easily enough.

The tricky part of using this class is getting the column’s ControlSource set up correctly. Typically, the purpose of using a combo in a grid is to bind the column to some foreign key value in the grid’s RecordSource while displaying the associated descriptive text from a lookup table. This means that when the column’s Sparse property is left at its default value of false, all rows except the current one display the foreign key value instead of the descriptive text. In order to get around this problem in the sample form, we set the Bound property of the grid column named ‘iColClientFK’ to false and its ControlSource to ( IIF( SEEK( Contacts.iClientFK, 'Clients', 'iClientPK' ), Clients.cCompany, '' ) ). Now the client name is displayed in all rows of the grid.

At this point you are probably saying to yourself “Hang on, there! Setting up the column’s ControlSource like that has the side effect of making the column ReadOnly!” and you would, in fact, be correct. However, when you run the example, you will see that you can still drop the list and make changes to the client for the current contact. The reason for this is that the ReadOnly attribute applies only to the portion of a control that accepts text. Since a drop down list does not accept text, it cannot be made read only (any more than a command button could be made read only). Fortunately, this behavior is documented and is by design so it is unlikely to change in future releases of the product.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform