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

Cell Highlighting

Thread ID:

Created:

Updated:

Platform:

Replies:

12812 Apr 13,2004 12:34 PM UTC Apr 15,2004 04:08 PM UTC WinForms 4
loading
Tags: GridControl
Steve
Asked On April 13, 2004 12:34 PM UTC

When highlighting a range of cells with the mouse, the first cell does not have the highlighted blue color. How can I add this first cell to have the highlighted color? It appears as though the highlighted range has a "hole." I understand that Excel does not highlight the first cell either, but I want to be different. :-) Thanks for your help, Steve

Administrator [Syncfusion]
Replied On April 13, 2004 03:36 PM UTC

Yon can handle the CellDrawn event and color it there. Below is a snippet. private void gridDataBoundGrid1_CellDrawn(object sender, GridDrawCellEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(e.ColIndex == cc.ColIndex && e.RowIndex == cc.RowIndex) { using(SolidBrush br = new SolidBrush(this.gridDataBoundGrid1.AlphaBlendSelectionColor)) { e.Graphics.FillRectangle(br, e.Bounds); } } }

Steve
Replied On April 13, 2004 06:34 PM UTC

Thanks Clay, but this code always highlights the current cell, I only want to highlight the current cell when multiple cells are selected via the mouse or shift arrows. Thanks.

Administrator [Syncfusion]
Replied On April 13, 2004 07:32 PM UTC

Try this code.
private void model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
	if(e.Range.Width > 1 || e.Range.Height > 1)
	{
		GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
		this.gridDataBoundGrid1.RefreshRange(cc.RangeInfo, true);
	}
}
private void gridDataBoundGrid1_CellDrawn(object sender, GridDrawCellEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(e.ColIndex == cc.ColIndex && e.RowIndex == cc.RowIndex
		&& this.gridDataBoundGrid1.Selections.Ranges.AnyRangeContains(cc.RangeInfo))
	{
		using(SolidBrush br = new SolidBrush(this.gridDataBoundGrid1.AlphaBlendSelectionColor))
		{
			e.Graphics.FillRectangle(br, e.Bounds);
		}
	}
}

Steve
Replied On April 15, 2004 04:08 PM UTC

Thanks, that worked!

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

;