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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ListBoxSelectionMode=MultiExtended and Change Selection Color

Thread ID:

Created:

Updated:

Platform:

Replies:

11130 Feb 24,2004 01:37 PM UTC Aug 12,2004 07:44 PM UTC WinForms 7
loading
Tags: GridControl
Lorin Boyer
Asked On February 24, 2004 01:37 PM UTC

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 03:59 PM UTC

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

Lorin Boyer
Replied On February 25, 2004 12:35 PM UTC

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 01:09 PM UTC

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 01:30 PM UTC

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 03:31 PM UTC

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
Replied On August 12, 2004 07:13 PM UTC

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 07:44 PM UTC

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

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;