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. Image for the cookie policy date

ListBoxSelectionMode=MultiExtended and Change Selection Color

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?

7 Replies

AD Administrator Syncfusion Team February 24, 2004 10:59 AM

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


LB Lorin Boyer 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)?


AD Administrator Syncfusion Team 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;
	}
}


LB Lorin Boyer 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?


AD Administrator Syncfusion Team 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().


FJ FJ 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


AD Administrator Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon