DOCERR: How to Set Column Index Correctly for AddColumn MethodID: Q135456 3.00 WINDOWS
The information in this article applies to:
SUMMARYThe Visual FoxPro Language Reference and Help file both list the following inaccurate information under the topic for the AddColumn method:
Although the columns do move to the right on the screen, the column index
is not incremented.
NOTE: The Visual FoxPro 3.0b for Windows documentation is correct.
MORE INFORMATIONThe column index is an internal array maintained by the grid object. Each column is assigned a subscript within the array. New columns are appended to the end of this array, and the array element number becomes the index for the column. The name of the column is determined by concatenating the word "Column" plus the index number converted to a string. If the AddColumn method is used to insert a column between columns 2 and 3 of a grid containing four columns, the name of the new column will be Column5. This can be confusing when it is necessary to refer to the columns later on because the column name does not reflect its position within the grid. If the Form.SaveAs method is used to save the form and the form is modified, the new column will appear at the end of all columns.
Step-by-Step ProcedureThe following method can be used to add a new column, set the order appropriately, and change the name of each column to reflect the new sequential order. If the Form.SaveAs method is used to save the form, the form will reappear with the columns in the desired order. 1. Create a new form, and add the C:\VFP\Samples\Mainsamp\Data\Customer.dbf 2. Add a grid to the form.
3. On the Form menu, click New Method. Name the method grdAddColumn and 4. Add a command button to the form, and put the following code in its
5. Save the form as frmAdd, and run it.
A new column will be inserted as the second column each time you click the the command button. All column names will be changed to reflect their position within the grid. Additional reference words: 3.00 VFoxWin KBCategory: kbdocerr KBSubcategory: FxprgGrid
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |