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

Change Grid AlphaBlendSelectionColor

Thread ID:

Created:

Updated:

Platform:

Replies:

7945 Oct 15,2003 12:13 PM UTC Oct 17,2003 01:19 PM UTC Windows Forms 9
loading
Tags: GridControl
James
Asked On October 15, 2003 12:13 PM UTC

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

James
Replied On October 15, 2003 12:22 PM UTC

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 02:53 PM UTC

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;
	}
}              

James
Replied On October 16, 2003 04:47 PM UTC

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 05:29 PM UTC

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;
	this.gridControl1.RefreshRange(GridRangeInfo.Row(cc.MoveToRowIndex));
	this.gridControl1.RefreshRange(GridRangeInfo.Row(cc.MoveFromRowIndex));
}    

James
Replied On October 17, 2003 10:11 AM UTC

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 10:58 AM UTC

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?

James
Replied On October 17, 2003 12:17 PM UTC

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

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

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

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

;