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

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 05:49 PM

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 06:54 PM

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 18, 2003 08:53 PM

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 18, 2003 08:59 PM

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 06:15 PM

> 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 01:50 PM

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

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