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!

grids, dynamiccolor and activatecell problems 1

Status
Not open for further replies.

samsnead

Programmer
Sep 3, 2005
100
CA
I made a posting some time ago about this topic and somehow got grids to respond properly. We put the dynamic code in the init of the grid

WITH THIS
.SetAll("dynamicbackcolor",;
"IIF(MOD(this.activerow, 2) # 0,RGB(255,254,210), RGB(255,255,255))", "Column")
ENDWITH
THIS.Refresh()

and coloring works ok until you scroll. In the scrolled we have
this.ActivateCell(1,1)

However, if I make field1 in the grid invisible the coloring works! Any suggestions on how to have field1 visible and coloring working?

 

Sam,

In the scrolled we have
this.ActivateCell(1,1)

That looks odd. Why would you want to activate the first cell after you have scrolled? Surely, it would simply negate the effect of the scolling.

I feel sure this is the cause of the problem. If you could explain what you are trying to achieve, perhaps we can suggest an alternative solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike - we put in the activatecell so that the alternate coloring of the grid rows would work. without it, scrolling would lose the alternating coloring.
 
Sam,

In that case, I'd try to figure out why scrolling the grid causes the alternating colours to be lost. There's no reason for that to happen. There must be something wrong somewhere in the grid.

Can you try removing the ActivateCell, then describe to us exactly the behaviour you are seeing (not just that it "doesn't work").

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
If I remove the activatecell from the scrolled method, the grid scrolls properly but the alternating colors for grid rows is lost. (focus no longer on grid?)

If I leave it in then alternating colors work but grid bounces back to first record in grid and the first record in the grid is the active row.

If I make field1 invisible and leave it in, the colors work and correct record in the grid is the active row.
 

I'm sorry, but this is still not clear. What EXACTLY happens when you remove the ActiveCell? When you say the "alternating colours are lost", do you mean that you don't see any backcolors at all, or all the rows are the same colour, or you see two colours but they don't alternate, or what?

Please understand -- I am not trying to be difficult. It's just that if you can't express a problem exactly, you can't expect an easy answer.

Also, it might help if you could post the code that sets the alternating colours - not the whole code for the form, just the bit that's relevant to this problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike

Code is in the init of the grid:
WITH THIS
.SetAll("dynamicbackcolor",;
"IIF(MOD(this.activerow, 2) # 0,RGB(255,254,210), RGB(255,255,255))", "Column")
ENDWITH
THIS.Refresh()

What happens - colors are all lost so background is white on all.
 
My apologies for having you post the code again. I see that you had already put it in your first message.

I can see the problem now. Instead of performing the test on this.activerow, it should be done on the record number. In other words:

Code:
WITH THIS
   .SetAll("dynamicbackcolor",;
      "IIF(MOD([b]RECNO("MyAlias")[/b]) # 0,RGB(255,254,210), RGB(255,255,255))", "Column")
ENDWITH

where MyAlias is the alias of the table that is populating the grid. This code should work, provided the table is not indexed and there are no deleted or out-filtered records.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top