How can I change color of a property(single property among all other properties) in CMFCPropertyGridCtrl
?
Asked
Active
Viewed 1,172 times
0

Suman Reddy
- 91
- 1
- 13
-
Can you please clarify? Do you mean the background colour? What have you tried? – Andrew Truckle Jun 20 '16 at 08:42
-
@AndrewTruckle actually I need to change back ground color and as well as text color of the property – Suman Reddy Jun 21 '16 at 04:25
2 Answers
3
You need to derive a class from the CMFCPropertyGridCtrol class, and override the CMFCPropertyGridCtrl::OnDrawProperty method. This allows you to change the device context to your liking prior to calling the default implementation:
class CMFCMyPropertyGridCtrl : public CMFCPropertyGridCtrl {
public:
virtual int OnDrawProperty( CDC * pDC, CMFCPropertyGridProperty* pProp ) const {
// Implement check to see, if this is the property we are looking for
// If it is, set an appropriate text color
pDC->SetTextColor( RGB( 0xff, 0x0, 0xff ) );
// Call the default implementation to perform rendering
return CMFCPropertyGridCtrl::OnDrawProperty( pDC, pProp );
}
};

IInspectable
- 46,945
- 8
- 85
- 181
0
CMFCPropertyGridCtrl.SetCustomColors(...) will do it.

winston
- 1
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 03 '23 at 09:16