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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing A Grid Created By A Wizard 1

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
Hello,

I'm having trouble with a grid that is embedded in a pageframe. The grid was created with the "wizard". It has combo boxes and check boxes, and text boxes. It works perfectly. When I go back and delete a column, all of the control sources for the controls "shift over" in the grid - regardless of the controls present. Example

Column: Column1 Coumnl2 Col3 Col4
Control: textbox checkbox combobox textbox
Control source: Name Married Relation place of birth

If I delete Col1, the controls remain as before but the control sources shift over.

Column: Col1 Col2 Col3 Col4
Control: textbox checkbox combobox textbox
Control source: Married Relation place of birth (next field in grid)

The code behind the controls also shifts to the new column - regardless of the type of control that is there. The code that was "behind" the original control in the grid shift along with the control sources of each column.

This is the real killer - now all of the column numbers in the code behind these controls NO LONGER WORKS because the code still refers to the old column numbers. Example:

Thisform.PageFrame1.Page4.Grid1.Column3.combo1.text is now in Col2 , not Col3 ... and there's a LOT of code behind some of these controls.

The same thing occurs if I add a new field into the table betwee two existing fields.
Even more damage occurs if I go back and use the grid's builder again.

1) Is there a work around?

2) Can you edit the .sct file?

3) Can you remove a control from a column once you've added it to the column and set it as the "current control" ?

4) Does VFP 8 address this problem?

At this point, any and all suggestions on handling grids - especially concerning rearranging columns AND the behavior of the "builder" for grids would be greatly appreciated.

Thank You,

Dave

The 2nd mouse gets the cheese.
 
The same thing occurs if I add a new field into the table betwee two existing fields.
Even more damage occurs if I go back and use the grid's builder again.


Obviously VFP will not "shit-over" columns without the "program" telling it to do so. Find the piece of code that makes the grid "shift" (By putting a "set step on")and correct the sitution

2) Can you edit the .sct file?

Yes you can, by using the form as a table, but not at runtime.
use myform.scx
browse

3) Can you remove a control from a column once you've added it to the column and set it as the "current control" ?

Yes, take a look at ADDOBJECT() and REMOVEOBJECT in the help file.

4) Does VFP 8 address this problem?

This seems to be a programming error that makes the grid "shift". My suggestions are:
1. find the problem in the code and correct the situation
2. Avoid using the "wizard" for anything other than "learning" how to do things. The wizard is great if when you using it you "leaves things as they are", but if you start adding code on top of what the wizard does, you may find that it reacts unexpectedly.
3. Coding errors happen all the time and I'm not sure that upgrading to VFP8.0 will "solve" this problem.





Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi mgagnon,

As for the builder, the problem isn't programmatic - it's just as you said... the builder is useless after the first time. Throw a grid down on a form and select 4 fields.(# 1 for a text box, #2 a checkbox,# 3 a combbox, and# 4 a text box. Now get out of the builder and add the checkbox and combo box controls to the columns as above. Set the columns "Current Control" properety to the desiredt controls. The grid is fine.

Now go back and run the builder and remove the field you used for column 2 and save the grid. When you look at the control sources, they've shifted over a column. In reality, any code that used to be behind a control went along with the shift. You wind up with the wrong type of control for the fields that have shifted and the references like thisform.grid1.column3.combo1.text refer to an item that is now in Column 2! Try it -( I'm using VFP 7.0 on a Win '98 FYI.)

Thank you very much for the info to edit a form. Is there any way to display the contents of a particular column in the form while browsing? Not just one cell - can I view the entire column's contents - let's say the objname memo field -all at once?

Thanks Again,

Dave

The 2nd mouse gets the cheese.
 

Now go back and run the builder and remove the field you used for column 2 and save the grid.

OF COURSE !! That is what I was refering to when I said "when you start changing things when things were created with the wizard, youy break whatever code the wizard generated". I don't see anywhere in your post where you specified that after removing the column you also fixed the code to make it work with this new configuration.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi mgagnon,

Sorry for the lack of clarity on my part, I was trying not to write a book in my example. I can better understand what you meant by,"when you start changing things when things were created with the wizard".

In my real project, i had code behind the GotFocus, LostFocus and the Valid Events of one combobox. After I removed an adjacent field from the grid using the "builder again" the column number references in these events were still referencing some of the other "original" Column numbers as they existed before the shift - like there's no longer a combobox under column3.

In my case, I was removing three columns and adding one. It was just easier to make a new grid and copy the code from the old grid's events to it before deleting it.

Thanks for your time,

Dave


The 2nd mouse gets the cheese.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top