Alphablending blues
My client has very specific color requirements for the grid, including the selection background color.
It seems the two options are either Alphablended or inverted color selection.
Here''s my problem: I have alternating row colors that are slightly different:
even rows: Color.FromArgb(246, 249, 251);
odd rows: Color.FromArgb(240, 242, 245);
The selected background color should be: Color.FromArgb(234, 246, 150)
To make matters even worse, the selected color should actually change to: Color.FromArgb(246, 249, 197) when the grid loses the selection.
So, my question is, is there any way I can get the selected background color to be specifically these values instead of alpha blending?
Thanks.
Pete
SIGN IN To post a reply.
7 Replies
AD
Administrator
Syncfusion Team
May 3, 2004 04:45 PM UTC
Try setting the AlphaBlendSelectionColor to Color.FromArgb(1,0,0,0).
Then handle PrepareViewStyleInfo and if e.RowIndex and e.ColIndex point to a selected cell, set e.Style.BackColor to the specific color you want.
//say in formload, use this to make the grid''s selection color not affect anything
this.gridControl1.AlphaBlendSelectionColor = Color.FromArgb(1,0,0,0);
//then handle this event to specify the backcolor of any selected cell.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(this.gridControl1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))
&& !this.gridControl1.CurrentCell.IsEditing)
e.Style.BackColor = mySelectionColor;
}
AD
Administrator
Syncfusion Team
May 3, 2004 05:07 PM UTC
Clay,
Worked like a charm, of course.
I have to say, every time I hit a snag with one of your controls and all I can think of as a solution is mucking about in the source code, you guys always have an elegant solution for me. Thanks.
Pete
AD
Administrator
Syncfusion Team
July 15, 2004 10:01 AM UTC
Clay
How do I have to set the color when ListBoxSelectionMode One is set? I would like to set the color to the same as in Outlook 2003(blue when standard themes are enabled).
Regards
Thomas
AD
Administrator
Syncfusion Team
July 15, 2004 10:33 AM UTC
Try this code in your PrepareViewStyleInfo (instead of what is above).
GridCurrentCell cc = this.grid.CurrentCell;
if(e.RowIndex == cc.RowIndex && e.ColIndex > 0)
e.Style.BackColor = Color.Blue;
AD
Administrator
Syncfusion Team
July 15, 2004 12:09 PM UTC
Hi Clay,
Thanks for the code. It works except that the color is slight different to the color I set. Might the AlphaBlend change the color? This property must be set, otherwise the color of the selection will be yellow.
Regards
Thomas
AD
Administrator
Syncfusion Team
July 15, 2004 12:37 PM UTC
If you set the alpha value of the grid selection color to 1 or zero, you can see a diffference?
this.gridControl1.AlphaBlendSelectionColor = Color.FromArgb(0, Color.Blue);
AD
Administrator
Syncfusion Team
July 15, 2004 12:50 PM UTC
Thanks Clay, that''s the way.
Regards
Thomas
SIGN IN To post a reply.
- 7 Replies
- 1 Participant
-
AD Administrator
- May 3, 2004 03:39 PM UTC
- Jul 15, 2004 12:50 PM UTC