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

Can someone explain why

Status
Not open for further replies.

chpicker

Programmer
Apr 10, 2001
1,316
Sorry about the poor subject, but I couldn't figure out a good way to compress this question.

I created a Grid class. The grid has a property called "cur_rec", which stores the current record (I use the AfterRowColumnChange event to store recno() into this property). The grid's INIT event uses SETALL to set the DynamicFontSize of each column based on the cur_rec property.

The actual line looks like this:
Code:
This.SetAll("DynamicFontSize","IIF(RECNO()=This.cur_rec,10,9"),"Column")
Now...this doesn't make any sense to me. Why do I have to use "This.cur_rec" instead of "This.Parent.cur_rec"? Doesn't "This" refer to the column, not the grid? Cur_rec is a property of the grid, not the column. Using the debugger shows that the DynamicFontSize does, indeed, belong to the column. If I put Parent in there, the expression is invalid, but leaving it out works fine.

As you can tell, I have the code working fine. My question is: why does it work this way? Does anyone know?
 
With this.parent.cur_rec your speaking to the form or container where your grid is on.
The command your using This.SetAll("DynamicFontSize","IIF(RECNO()=This.cur_rec,10,9"),"Column") is in the grid object, so this. points to the grid-object. The property you've added is added to the grid class (not object) so you said. So you can speak to it with this.

I hope it has helped...

Charl
 
HI..

The code is put in the INIT event of the grid. The init event belongs to the grid and not to the COLUMN. So when you say THIS. it refers to the Grid and not the column.

[What you say could be correct .i.e. This.Parent.. if the init event is of the column of the grid.].. Hope this explains your question.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
It kinda makes sense...however, the "this.cur_rec" is actually set into the DynamicFontSize property of the column, not the grid. This is what I am confused about. I pulled up the Debugger and confirmed that the Column object is, in fact, what contains the string "IIF(RECNO()=This.cur_rec,10,9)".

I haven't tried it, but I bet if I directly set each column's DynamicFontSize property individually to this string that it would not work. However, using SetAll from within the grid actually references the grid, even though it is the column that is receiving the property.

Do you see where my confusion is coming from?
 
Your right, very strange....

I did use it also in that way, using parent gives me the error expression in dynamicColor.

But when looking in the debugger, the parent from the column object is the grid, and the column object has no public/global reference to cur_rec

So it is indeed very strange???

I'm also interested what the real reason from this story is?

Charl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top