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
close icon

Override Selection Color in GridListControl

Hi, How can I override the selections backcolor in GridListControl? Currently, it's fixed at the lightblue color and alpha-blend with the backcolor of the cell. Even better, can I use different backcolor without alpha-blending on different cells in the selections? Aaron

7 Replies

AC Aaron Ching June 18, 2003 09:49 PM UTC

Similar question: Can I override the selection backcolor in the regular GridControl? I want to control the selection backcolor very precisely, without any alpha-blending or default coloring.


AD Administrator Syncfusion Team June 18, 2003 10:54 PM UTC

If you want to use the grid's selection drawing support, it is either use alphablending or inverting the colors that exist in the selected cells. Usually alphablending gives a nicer look. If you want to manage things yourself, you can try using PrepareViewStyleInfo on the embedded GridControl.
//in formload
gridListControl1.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(grid_PrepareViewStyleInfo);
gridListControl1.Grid.AlphaBlendSelectionColor = Color.FromArgb(1, 0, 0, 0);


//the handler
private void grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(this.ListBox1.Grid.Selections.GetSelectedRows(true, false).AnyRangeIntersects(GridRangeInfo.Cell(e.RowIndex,e.ColIndex)))
	{
		e.Style.BackColor = Color.LightGoldenrodYellow;
	}
}


AC Aaron Ching June 19, 2003 12:53 AM UTC

How can I turn off the invert coloring on selected cells in GridControl? Even with your suggested codes, my GridControl is still showing the inverted color on selected cells.


AC Aaron Ching June 19, 2003 12:59 AM UTC

BTW, your suggested codes work fine if default value is used for AllowSelection. However, the color inversion occur when GridSelectionFlags.Shift and GridSelectionFlags.Multiple are used.


AD Administrator Syncfusion Team June 19, 2003 10:15 PM UTC

> BTW, your suggested codes work fine if default value is used for AllowSelection. However, the color inversion occur when GridSelectionFlags.Shift and GridSelectionFlags.Multiple are used. > Make sure you combine the Shift and Multiple flags together with GridSelectionFlags.AlphaBlend. Then the selection should not be inverted. Stefan


AC Aaron Ching June 20, 2003 05:50 PM UTC

Hi, I did add the GridSelectionFlags.AlphaBlend as follows: this.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Multiple | GridSelectionFlags.Shift; The color inversion issue is solved but now the multiple and shift selection stop working. Would this be a bug? -- Aaron


AD Administrator Syncfusion Team June 20, 2003 06:09 PM UTC

Try also setting GridSelectionFlags.Row|GridSelectionFlags.Cell Without "Cell" any selection mechanism won't work. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon