Avatar of IainMacb
IainMacb
Flag for United Kingdom of Great Britain and Northern Ireland asked on

.SETALL() method not working on all columns

I'm getting an odd result when using the .SETALL() method in a grid.

I'm trying to highlight the 'current' record. In the .INIT() method for the grid object I've got a line of code that is

    WITH THIS
            .SetAll("DynamicBackColor", ;
                  "IIF( THIS.RecordNumber = RECNO(THIS.RecordSource), c_current, c_normal )", "Column")

The IIF() is handling the moving of the current record, and that works OK.
C_CURRENT and C_NORMAL are the two colours - C_CURRENT is usually highlight yellow while C_NORMAL is usually white, but they can be changed by the user.

Now, what's happening is that I've got 17 columns in the grid. The .SETALL() works OK for the first 14, but not for the last three for some reason.

Any suggestions as to what I'm doing wrong?
FoxPro

Avatar of undefined
Last Comment
IainMacb

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Olaf Doschke

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
IainMacb

ASKER
Each of the columns contains a boringly-standard text entry.

Using version 9.0 SP2.

Will go and look at Highlight.
IainMacb

ASKER
Have looked at .Highlight and its related properties.

Much simpler solution than .SETALL()! I must have installed .SETALL() years ago and never noticed the alternative - when did it arrive?

New code inserted, all working happily now - many thanks.
Olaf Doschke

Highlight properties were introduced in VFP8 I think, and have improved a little in VFP9.

Much easier for current record highlighting. You can still make use of dynamic color properties, though. The donwside is, the highlight colors don't automatically mix with the other colors to give an overlay/color filter look.

Bye, Olaf.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
IainMacb

ASKER
I probably wasn't paying attention to changes in VFP8.

Meanwhile, I see what you mean about the colours. I'm using red to mark negative values - but these disappear in the highlighted row:

Screen capture
Olaf Doschke

You may revert to setting the dynamicbackcolor. Setall not working on all columns points out, you may add some columns later than you think. Setall only works on all objects existing at that time, of course. If you reset the recordsource, you get new columns, for example, and they don't "inherit" the settings of already existing columns (they are siblings, not children anyway).

Bye, Olaf.
IainMacb

ASKER
Doh! (to quote Homer Simpson)

I've just looked in more detail at the order in which everything gets called. What I thought was happening - that the grid and its columns gets created and then we call .SETALL() ISN'T what's happening. It's the other way round.

So I've now moved my original .SETALL() code to be in the 'right' place, after the grid and the columns are created. And surprise, surprise, it's all working properly,
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.