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

ListBoxSelectionMode=MultiExtended and Change Selection Color

Thread ID:





11130 Feb 24,2004 08:37 AM Aug 12,2004 03:44 PM Windows Forms 7
Tags: GridControl
Lorin Boyer
Asked On February 24, 2004 08:37 AM

I''m currently able to change the selection color of the currently selected row by using the PrepareViewStyleInfo event. However, all the other rows that are selected have the AlphaBlendSelectionColor. How do I control the selection color of all the rows that are selected?

Administrator [Syncfusion]
Replied On February 24, 2004 10:59 AM

Will changing the grid.AlphaBlendSelectionColor property do what you want?

Lorin Boyer
Replied On February 25, 2004 07:35 AM

I''ve tried changing the alphablendselectioncolor. Each color I assign to it is then alpha blended to a lighter version of the color I sent in. Is there a way to turn that off (so that it doesn''t make the color lighter)?

Administrator [Syncfusion]
Replied On February 25, 2004 08:09 AM

Try setting the alpha part of the selection color to 1, and then handle PrepareViewStyleInfo to set the backcolor of the cell if it is selected. this.gridDataBoundGrid1.AlphaBlendSelectionColor = System.Drawing.Color.FromArgb(1, 178, 180, 191);
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.ColIndex > 0 && e.RowIndex > 0 
		&& this.gridDataBoundGrid1.Selections.GetSelectedRows(true, true).AnyRangeContains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))) 
		e.Style.BackColor = Color.DodgerBlue;

Lorin Boyer
Replied On February 25, 2004 08:30 AM

ok, that works. However, when the grid loses focus that selected rows continue to have the selected color. Is there a way to turn that off when the grid loses focus?

Administrator [Syncfusion]
Replied On February 25, 2004 10:31 AM

Add ''this.gridDataBoundGrid1.HasControlFocus &&'' at the start of the if condition in PrepareViewStyleInfo. Also, handle the grid.Leave event, and in your habdler, call grid.Refresh().

Replied On August 12, 2004 03:13 PM

Hello I''m trying to do almost the same thing, and it''s working ALMOST ok. My remainding problems are: 1. When I click on any of the header columns (row 0 in my GridDataBoundGrid) the current cell within the currently highlighted row becomes unhighlighted, so the complete current row remains hightlighted except for the current cell. 2. The first time the Grid is shown, the first row is shown hightlighted in a colour other than the one I want. It looks like it''s using a default setting. As soon as I click on it or any other row, the Selected Row shows in the proper colour. Thank you so much in advance. FJ

Administrator [Syncfusion]
Replied On August 12, 2004 03:44 PM

I cannot see either of these behaviors in the sample below. 2) Make sure the PrepareViewStyleInfo event has been subscribed to before the grid is painyted for the first time. 1) Are you handling any click events or other events thiat might be affecting this problem? WindowsApplication8_1693.zip


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