Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 is currently offline  forlano
Messages: 1185
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>());   
...
Previous Topic: Custom abort of HttpClient::Execute()
Next Topic: bad visualization of a column list
Goto Forum:
  


Current Time: Mon Apr 29 02:24:54 CEST 2024

Total time taken to generate the page: 0.03298 seconds