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.

Change Grid AlphaBlendSelectionColor

Thread ID:





7945 Oct 15,2003 08:13 AM Oct 17,2003 09:19 AM Windows Forms 9
Tags: GridControl
Asked On October 15, 2003 08:13 AM

Hi, I change grid.AlphaBlendSelectionColor to Color.FromArgb(255, SystemColors.Highlight) to make the selection color same as standard windows highlight color. However, the grid selection color still does not look the windows highlight color. It seems like the grid only take opaque at fixed 64. How can I change that? Thank you in advance. James

Replied On October 15, 2003 08:22 AM

Related question: How can I make the grid row selection like windows listview (selected text's color changed to white)? Thanks! James

Administrator [Syncfusion]
Replied On October 15, 2003 10:53 AM

I think you can both items through the PrepareViewStyleInfo event.
private void Form1_Load(object sender, System.EventArgs e)
	this.gridControl1.ListBoxSelectionMode = SelectionMode.One;
	this.gridControl1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow;
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.ColIndex > 0 && e.RowIndex == this.gridControl1.CurrentCell.RowIndex)
		e.Style.BackColor = SystemColors.Highlight;
		e.Style.TextColor = Color.White;

Replied On October 16, 2003 12:47 PM

It works fine except the selected color becomes default AlphaBlendSelectionColor when grid lost focus. How can I control the deactivated row (cell) color? Thanks!

Administrator [Syncfusion]
Replied On October 16, 2003 01:29 PM

You can try using CurrentCellMoved to refresh both the old and new row.
private void gridControl1_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;

Replied On October 17, 2003 06:11 AM

It works when moving within the gird. The problem is the selected row's color has changed to default AlphaBlendSelectionColor when the focus is moved to other control in the form.

Administrator [Syncfusion]
Replied On October 17, 2003 06:58 AM

I myy be missing something, but I do not see this behavior in the attached project when I click on the button to cause the grid to lose focus. Do you?

Replied On October 17, 2003 08:17 AM

I changed current row's color as following: private void gridControl1_PrepareViewStyleInfo(...) { // if current row { e.Style.BackColor = SystemColors.Highlight; e.Style.TextColor = Color.White; } } I have grid and other buttons in a form. When I select a row in the grid, the current row's color is changed to system highlight color. Whenever I click a button on the form, the focus is moving away from grid, the slected row's color is changed to AlphaBlendSelectionColor. Just wondering where the grid does the change and how to to override it to change to system highlight color.

Administrator [Syncfusion]
Replied On October 17, 2003 09:10 AM

Can you post a sample project showing the problem? I could not see it in the sample I uploaded. I think I did exactly what you described. Could you see the problem in the sample I uploaded?

Administrator [Syncfusion]
Replied On October 17, 2003 09:19 AM

Try setting this.gridControl1.AlphaBlendSelectionColor = Color.FromArgb(1, SystemColors.Highlight); to see if that affects anything for you.


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.

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.