Yes, it can be confusing, I agree.
My point is that you need to write code in the BackStyle_Assign method, even though you are not aiming to change the backstyle property. For reasons that I won't go into, BackStyle_Assign fires whenever the form is repainted, and it fires separately for each row in the grid (that's a bit of an over-simplification, but never mind).
What's important is that you can use the code in BackStyle_Assign to change any aspect of the container, whether that be the fore or back colour, the font name, the font size, or just about anything else.
You create BackStyle_Assign at the class level. Remember, this is a method of the container, so you will need a custom container class. It is this class that you drop into a column of the grid in order to create your multi-line grid.
Assuming you have a suitable container class, proceed as follows:
1. Open the class in the class designer.
2. From the Class menu, select Edit Property/Method.
3. In the resulting list of properties, select BackStyle, then tick the box labelled Assign Method.
4. Click Apply. Close the dialogue.
5. A method named
backstyle_assign (all in lower case) will now appear along with all your other methods for the class. For example, it will appear in the Methods tab of the Properties window (because it is all in lower-case, it will appear at the very end of the list of methods).
6. When you open the method for editing, you will see this code already in place:
Code:
LPARAMETERS vNewVal
*To do: Modify this routine for the Assign method
THIS.BackStyle = m.vNewVal
You need to retain that code (although you can remove the To-do comment), but you also need to incorporate your own code to actually change the properties of the container. For example, suppose your grid contains sales invoices, and you want to show invoices that are overdue with a thick red border, you might do this:
Code:
LPARAMETERS vNewVal
IF Invoices.DueDate < DATE()
THIS.BorderColor = 255
THIS.BorderWidth = 2
ELSE
THIS.BorderWidth = 0
ENDIF
THIS.BackStyle = m.vNewVal
You see, even though it is the Backstyle's Assign method that you are editing, your code is only concerned with the border colour and width - nothing to do with the Backstyle itself.
By the way, Access and Assign methods were introduced in VFP 6.0, so all this should work fine.
Once you've got this working, you might want to read more about Access and Assign methods, as they open the door to lots of possibilities. I wrote a long article about them in FoxPro Advisor, but unfortunately I no longer have an electronic copy I can give you. Doug Hennig also wrote a paper about them, which you should be able to search for.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads