Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » How to set the color of a row
|
Re: How to set the color of a row [message #7714 is a reply to message #7713] |
Tue, 16 January 2007 22:29 |
|
forlano wrote on Tue, 16 January 2007 15:46 | Hello,
this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?
Luigi
|
GridCtrl:
grid.GetRow(22).Bg(Red);
|
|
|
|
Re: How to set the color of a row [message #7728 is a reply to message #7727] |
Wed, 17 January 2007 12:28 |
|
forlano wrote on Wed, 17 January 2007 06:06 |
unodgs wrote on Tue, 16 January 2007 22:29 |
GridCtrl:
grid.GetRow(22).Bg(Red);
|
I've used it at runtime, not in the constructor, and I discovered that was necessary to add the instruction grid.Repaint() to see the new color. I guess this is normal.
Luigi
|
I think it has to be change. Bg and similar functions should refresh the grid. Calling Repaint is not optimal as it recalculate rows/columns (if needed) positions and repaint the whole content.
I used Bg mainly in callbacks where calling refresh is not necessary as outer functions that call callbacks do this.
Anyway it will be fixed before final release.
PS: It's better to call RefreshRow(int n) instead of Repaint
|
|
|
Re: How to set the color of a row [message #34272 is a reply to message #7727] |
Mon, 07 November 2011 16:27 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
I used
grid.GetRow(x).Bg(Red);
to set red the color of some row of a gridctrl where the rows are white and blu depending of their parity
( grid.ColorRows().EvenColor(SColorText, Blend(SColorMark, SColorPaper, 220)); ) .
The red color depend of the value in a coloumn. So in some case the cell need to be set at its default color.
How to remove the red color and leave the default color?
Thanks,
Luigi
[Updated on: Mon, 07 November 2011 16:41] Report message to a moderator
|
|
|
|
|
|
Re: How to set the color of a row [message #34322 is a reply to message #34317] |
Fri, 11 November 2011 20:55 |
Didier
Messages: 680 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi Forlano,
I had to do something approaching and I used a gridDisplay for it:
class BgColorGridDisplay : public GridDisplay
{
private:
Color _bg; //(140, 140, 140);
public:
BgColorGridDisplay(const Color color)
: _bg(color)
{}
virtual 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 = false, int fs = 0, int fe = 0)
{
if (found)
{
GridDisplay::Paint(w,x,y,cx,cy,val,style,fg,bg,fnt,found,fs,fe);
}
else
{
GridDisplay::Paint(w,x,y,cx,cy,val,style,fg,_bg,fnt,found,fs,fe);
}
}
};
You can either remove the display to restore original color or enhance it to keep it form overwriting original color.
tabGrid.dataGrid.AddColumn("ColName", 110).SetDisplay( greyBgDisplay )
I use it in order to change bkgnd colour of only some columns while others are changed on cell value just like you.
|
|
|
Goto Forum:
Current Time: Sat May 04 14:36:19 CEST 2024
Total time taken to generate the page: 0.02704 seconds
|