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

hilite entire row

How can I make the entire row (including the current cell) hilited? I''m using a GDBG control. Currently, when the user clicks in a cell, the cell they clicked in is white and the rest of that cell''s row is light gray. How can I make the whole row (including the current cell) change color, and how can I set the color the row is hilited with? I''d prefer it to be a darker color (maybe a dark blue with white text). ----- Lee

6 Replies

Administrator June 28, 2004 11:28 AM UTC

Hi You can set grid.ListBoxSelectionMode = SelectionMode.One. Doing so will select the row when you click on a cell. But the CurrentCell will be active. This means its background will not match the rest of the selected row. To make the CurrentCell look like the rest of the row, subscribe to the CurrentCellActivating event. In your handler, set e.ColIndex = 0. This will make the current cell be on the header, and not conflict with the rest of the selected row. From KB link: http://www.syncfusion.com/Support/article.aspx?id=579 Mark Not a Syncfusion Employee

LP Lee Perkins June 28, 2004 12:22 PM UTC

That worked great... until I realizes the the CurrentCellControlDoubleClick event wasn''t firing any more. I need to perform some action if the row is double clicked. I was handling that in the CurrentCellControlDoubleClick event, but now that I''m moving focus away from the current cell as soon as it gets it, the user can no-longer double-click on a cell. Any idea how I could work around this? I need the whole row to hilite (including the current cell), and I need the user to be able to double click on a row. ----- Lee

Administrator June 28, 2004 12:43 PM UTC

You can try this. Still use the ListBoxMode that Mark suggested, but do not handle CurrentCellActivating. Instead handle CurrentCellDrawn and paint the current cell there to match the rest of the selections.
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);
		}
	}
}

LP Lee Perkins June 28, 2004 01:05 PM UTC

That didn''t work. The current cell does draw with the hilite color, briefly... then it redraws with a white background when it places the blinking caret in the cell. ----- Lee

Administrator June 28, 2004 01:45 PM UTC

If you are letting the current cell become active, then it will repaint itself with the style.BackColor for the cell. The simplest way to avoid this is to not let the cell show an edit cursor by setting this property. this.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.None;

LP Lee Perkins June 28, 2004 02:22 PM UTC

Thanks! That did the trick perfectly. ----- Lee
Loader.
Live Chat Icon For mobile
Up arrow icon