We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Alphablending blues

Thread ID:

Created:

Updated:

Platform:

Replies:

13587 May 3,2004 03:39 PM UTC Jul 15,2004 12:50 PM UTC Windows Forms 7
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 3, 2004 03:39 PM UTC

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

Administrator [Syncfusion]
Replied On 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;
}

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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;

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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);

Administrator [Syncfusion]
Replied On July 15, 2004 12:50 PM UTC

Thanks Clay, that''s the way. Regards Thomas

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;