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

GridGroupingControl No Row Selection color

Hi, How would I remove the row selection colour from all data cells in a row apart from the row header. Regards Dev.

3 Replies

Administrator October 5, 2004 01:04 PM UTC

So, you want to color the header of the current row. Is this what you want? If so, you might try this code: this.gridGroupingControl1.ThemesEnabled = false; this.gridGroupingControl1.TableControlCurrentCellMoved += new GridTableControlCurrentCellMovedEventHandler(gridGroupingControl1_TableControlCurrentCellMoved); this.gridGroupingControl1.TableControl.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(TableControl_PrepareViewStyleInfo);
private void gridGroupingControl1_TableControlCurrentCellMoved(object sender, GridTableControlCurrentCellMovedEventArgs e)
{
	this.gridGroupingControl1.TableControl.RefreshRange(GridRangeInfo.Cell(e.TableControl.CurrentCell.MoveFromRowIndex, 0));
}
private void TableControl_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex ==0 && this.gridGroupingControl1.TableControl.CurrentCell.RowIndex == e.RowIndex)
		e.Style.BackColor = Color.Blue;
}

DH Devshi Halai October 5, 2004 01:48 PM UTC

Hi Clay, This is not exactly what I was after. If I click on a data item in a row, I don''t want the row to be highlighted in any way. I only want the row header for that row highlighted. ( this is the code you replied in the last message).

Administrator October 5, 2004 02:52 PM UTC

Try handling these two events.
private void gridGroupingControl1_TableControlCurrentCellMoved(object sender, GridTableControlCurrentCellMovedEventArgs e)
{
	this.gridGroupingControl1.TableControl.RefreshRange(GridRangeInfo.Cell(e.TableControl.CurrentCell.MoveFromRowIndex, 0));
}

private void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e)
{
	if(e.Inner.ColIndex == 0 && 
		e.TableControl.CurrentCell.RowIndex == e.Inner.RowIndex)
	{
		using (Brush b = new SolidBrush(Color.FromArgb(60, Color.Blue)))
		{
			e.Inner.Graphics.FillRectangle(b, e.Inner.Bounds);
		}
	}
}
Loader.
Live Chat Icon For mobile
Up arrow icon