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

Odd Grid Behavior

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,828
JP
All,
I have a grid on a form (it is a sub-class of the base grid, with a few minor proprties set). I have placed on on my form, and then used the "Builder" to set it up to look like I want. I have slected the "Ledger" style for display.
The odd behavior I have, is that sometimes the ledger lines are "doubling up". In other words, instead of having a white line, then a green line, I get 2 green lines in a row... I had some suspision that this is caused by the index that I have set on for one field, which is causing the order of the items to be shuffled, but I would have expected the grid colors to remain constant in their alternating color pattern. Can anyone tell me how to fix this, and keep the current index (Alphabetical for the first field of the two displayed) in the box???



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Ahhh... I see it in the "DynamicBackColor" as a property of the row in a column... and VFP has put in a MOD(2) to mark odd rows white, and even rows green, which is fine for natural order, but disasterous if you set an index on... Anyone have any clever code to drop into this property to make it work as would otherwise???



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 

Scott,

Your diagnosis is spot on. The builder's method of creating the ledger style relies on the table being in record number order. The fact that you have an index defeats the whole thing.

The usual solution is to add an extra (numeric) field to the underlying table or cursor. When you set the index order, or update the underlying table, you scan the table, inserting a consecutive number into that field. You then use that field rather than the record number in the DynamicBackColor condition.

Unfortunately, this could have a bad effect on performance if you have a large table, so you have to ask yourself how badly you want this style.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike... BAH! I knew that was going to be your answer. That really depresses me... is there no way to get the order from the index, and use that instead???
-S

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Geoff,
That is probably a possibility, but I was also using the grid as a means of "Fast navigation" through a relatively small-ish (usually 5 to 10, but could be as large as 100) items in a list... I think I may ditch the pretty bars, and just allow users to scroll it and pick it, or type the first few letters of the key column, and have it "Find as you fill" with an Interactive Change event, highlighting the row as the record is "found"... not really what I wanted, but it will still look nice. I had contemplated pulling it into an array, or a "linking" table, that would hold the real record numbers too, and not display it, and just issue a "GO TEMPTABLE.RECNO" on the actual table, to jump to the desired record... but that gets messy, when I have about 50 of these type of "Configuration" screens I have to create for my application...

Was hoping for some ultra-clever IIF() condition that someone has come up with... but I am losing hope of that rapidly.



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top