下面是设置单独颜色和字体,请问这个怎么重载能详细说下具体步骤设置,谢谢!
If we want to change the foreground/background color or the font style (bold, italic, underline), then we can override the methods CGridListCtrlEx::OnDisplayCellColor() and CGridListCtrlEx::OnDisplayCellFont().
bool MyGridCtrl::OnDisplayCellColor(int nRow, int nCol, COLORREF& textColor, COLORREF& backColor)
{
if (nRow == 3 && nCol == 3)
{
textColor = RGB(0,255,0);
backColor = RGB(0,0,255);
return true; // I want to override the color of this cell
}
return false; // Use default color
}
------解决思路----------------------
下面是设置单独颜色和字体,请问这个怎么重载能详细说下具体步骤设置,谢谢!
If we want to change the foreground/background color or the font style (bold, italic, underline), then we can override the methods CGridListCtrlEx::OnDisplayCellColor() and CGridListCtrlEx::OnDisplayCellFont().
bool MyGridCtrl::OnDisplayCellColor(int nRow, int nCol, COLORREF& textColor, COLORREF& backColor)
{
if (nRow == 3 && nCol == 3)
{
textColor = RGB(0,255,0);
backColor = RGB(0,0,255);
return true; // I want to override the color of this cell
}
return false; // Use default color
}
红色的语句改成你需要的行列,颜色改成你需要的颜色就是重载啊
------解决思路----------------------
自定义个类 从CGridListCtrlEx 派生 会吧?
------解决思路----------------------
给这个自定义类添加函数
bool MyGridCtrl::OnDisplayCellColor(int nRow, int nCol, COLORREF& textColor, COLORREF& backColor)
{
if (nRow == 3 && nCol == 3)
{
textColor = RGB(0,255,0);
backColor = RGB(0,0,255);
return true; // I want to override the color of this cell
}
return false; // Use default color
}
然后使用这个类声明一个控件 使用就ok了