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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change color of Selected row in GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

26364 Mar 22,2005 12:12 AM UTC Oct 21,2005 02:49 PM UTC WinForms 4
loading
Tags: GridControl
Sammy Desir
Asked On March 22, 2005 12:12 AM UTC

Hi How do I change the color of Selected row in GridDataBoundGrid? Thanks

Administrator [Syncfusion]
Replied On March 22, 2005 12:59 AM UTC

If you have the GridSelectionFlags.AlphaBlend set in the grid.AllowSelection property, then you can control the selection color using the grid.AlphaBlendSelectionColor property.

Dimitar Binev
Replied On October 21, 2005 01:33 PM UTC

But this also changes the text color and in my case that''s not what I want. Is there any other way to change the selection color? >If you have the GridSelectionFlags.AlphaBlend set in the grid.AllowSelection property, then you can control the selection color using the grid.AlphaBlendSelectionColor property.

Administrator [Syncfusion]
Replied On October 21, 2005 02:13 PM UTC

Try hiding the selection color and then directly set the BackColor in PrepareViewStyleInfo. To manage the currentcell getting colored(if you want this), you can refresh in in SelectionsChanged.
this.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.FromArgb(0,0,0,0);
this.gridDataBoundGrid1.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(gridDataBoundGrid1_PrepareViewStyleInfo);
this.gridDataBoundGrid1.Model.SelectionChanged += new GridSelectionChangedEventHandler(Model_SelectionChanged);



private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(this.gridDataBoundGrid1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex)))
	{
		e.Style.BackColor = Color.Red;
	}
}

private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
	if(e.Range != null)
	{
		this.gridDataBoundGrid1.RefreshRange(this.gridDataBoundGrid1.CurrentCell.RangeInfo, true);
	}
}

Dimitar Binev
Replied On October 21, 2005 02:49 PM UTC

Thanks Clay, That''s exactly what I needed! And came at lightning speed :) Warm Regards, Dimitar

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

;