Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Column Trick with Sparse=.Y. and ComboBox
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Grid Column Trick with Sparse=.Y. and ComboBox
Miscellaneous
Thread ID:
00358642
Message ID:
00358642
Views:
58
I often want to see the description of a field instead of the Id#. For example on an invoice I want to see the product description not the product number in a grid column.

This can be accomplished using the ComboBox control and then setting Sparse to .N. However, this reduces the grid performance as it takes longer to refresh the grid. Fortunately, I found another method.

The code for the grid column and the combox is shown below. This only works if the ComboBox Style is set to "2".

The controlsource setting for the column causes the Product to be located and the description displayed in textbox. When you clikc on the column the combobox is activated and you can look up the product. The speed is much better because the Sparse property is set to .Y.

With mygrid.column1
.ControlSource="IIf(Seek(Inv.PrdNo,'Product','IdNo'),Product.Desc,'')"
.Header.Caption="Product Description"
.Sparse=.Y.
.Bound=.N.
.comProduct.Style=2
.comProduct.ControlSource="Inv.PrdNo"
.comProduct.StatusBarText="Select the product from the pop-up list."
.comProduct.RowSource="Product.Desc,IdNo"
.comProduct.RowSourceType=6
.comProduct.ColumnCount=2
.comProduct.ColumnWidths="200,50"
.comProduct.BoundColumn=2
endWith

This is also useful for showing time in am/pm mode but storing the time in 24 hour format in the table. I just created a lookup table with 1440 records one for each minute of the day. Now there is no more time conversion. It is simply a lookup.

Simon White
dCipher Computing
Simon White
dCipher Computing
Reply
Map
View

Click here to load this message in the networking platform