Home » U++ Library support » U++ Library : Other (not classified elsewhere) » background color of the cell in the GridCtrl
background color of the cell in the GridCtrl [message #6755] |
Sun, 26 November 2006 11:20 |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
today I succeseded in coloring the cell of a gridctrl. It was not obvious to me. Moreover it uses different method of the arrayctrl. I want to share the snippet. In a column I want the background be green or red depending by the value 0/1 of the cell:
class ColoredStatus : public GridDisplay
{
public:
void Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe);
};
void ColoredStatus::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe)
{
if( AsString(val) == "1" ) bg = Color(0, 255, 0);
else bg = Color(255, 0, 0);
GridDisplay::Paint(w, x, y, cx, cy, val, style, fg, bg, fnt, found, fs, fe);
}
...// then set the column
arrPlayer.AddColumn("Status", t_("Status"), 4).Edit(optStatusP).SetDisplay(Single<ColoredStatus>());
...
|
|
|
Goto Forum:
Current Time: Mon Apr 28 20:38:02 CEST 2025
Total time taken to generate the page: 0.00553 seconds
|