Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding column to grid 1

Status
Not open for further replies.

samsnead

Programmer
Sep 3, 2005
100
CA
I have a grid with 9 columns, data is bound to grid and control source is set to field in cursor. If a certain condition exists, I want to add a column to the grid, show that column as the second column and show all other columns. When I do this, the columns show properly but the data displays in original position in grid but not in the correct column. As an example, if column2 was a code,column 3 originally had the date and column 4 had a description, the date shows in the code column and the description in the date - this is in the cursor field order. Is there a way around this?

I tried setting bound to .F. on all but didn't work.
 
Y - I thought that since controlsource was set to column in grid it would automatically move - appears I am wrong!

I temporarily got around this by modifying the select so that data is in order I want based on number of columns.
 
No, not only will the ControlSource not move with the columns -- nothing else will either. The caption, column width, format, input mask -- all these things stay with the column.

But modifying the SELECT is also a good way to go.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Assuming that you already know how to dynamically add a new column to the existing Grid...

If an additional column was dynamically added and you wanted to re-order the Grid's display, but retain all of the other individual Column settings, you should be able to just manipulate the GRID.COLUMNn.COLUMNORDER value.

For example THISFORM.GRID.COLUMN9.COLUMNORDER = 2 would display your new Column #9 in the Grid's column position #2. Typically you cycle through all of the remaining columns re-setting their COLUMNORDER value as well.

Don't forget to do a THISFORM.GRID.REFRESH after the re-order work.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top