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

Change Grid AlphaBlendSelectionColor

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

9 Replies

JA James 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


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


JA James 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!


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


JA James 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.


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


JA James 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.


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


AD Administrator Syncfusion Team October 17, 2003 09:19 AM

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

Loader.
Live Chat Icon For mobile
Up arrow icon