What is a user attribute?
User Attributes help you store information in cells that can be interpreted by custom cell types. Suppose you implement a new cell type CMyEditControl. One feature of that new cell type is that the text should be drawn underlined when the value in the cell is greater than a given number. The number should be different for individual cells.
This number is a good example for using user attributes. If you register a new user attribute with the id IDS_UA_COMPARENUMBER, you can apply this user attribute to individual cells with SetStyleRange and SetUserAttributeand in CMyEditControl read this attribute with GetUserAttribute.
Example:
Apply number to individual cells
SetStyleRange(CGXRange(nRow, 1), CGXStyle()
.SetControl(IDS_CTRL_MYEDIT)
.SetUserAttribute(IDS_UA_COMPARENUMBER, 100)
);
SetStyleRange(CGXRange(nRow, 2), CGXStyle()
.SetControl(IDS_CTRL_MYEDIT)
.SetUserAttribute(IDS_UA_COMPARENUMBER, 200)
);
In CMyEditControl you can read this user attribute
// read number
double number = atof(m_pStyle->
GetUserAttribute(IDS_UA_COMPARENUMBER));