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.

Cell Highlighting

Thread ID:

Created:

Updated:

Platform:

Replies:

12812 Apr 13,2004 08:34 AM Apr 15,2004 12:08 PM Windows Forms 4
loading
Tags: GridControl
Steve
Asked On April 13, 2004 08:34 AM

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 11:36 AM

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 02:34 PM

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 03:32 PM

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 12:08 PM

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.

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.

;