GridSelection

Hello, i have a gdg attached to a CurrencyManager and i use "PrepareViewStyleInfo" event for color my selected line. I want only columns can be selected (no multiple lines, no multiple cells) but i want to be able to click on a line (cell) to raise an event and retrieve my row in the code. So i use the code: gdg.AllowSelection = GridSelectionFlags.Column | GridSelectionFlags.AlphaBlend | GridSelectionFlags.Multiple; It works fine but i have always the selected line active (sometimes my current row, sometimes not so i have one line colored by selection and another by my code in "PrepareViewStyleInfo") I want to disable the selected line is it possible ? I try gdgCampagne.ListBoxSelectionMode = SelectionMode.None but it doesn''t work.

6 Replies

AD Administrator Syncfusion Team February 15, 2005 12:58 PM UTC

Try setting grid.AlphaBlendSelectionColor = Color.FromArgb(0, grid.AlphaBlendSelectionColor); This code makes the alpha value of the selection color to be zero, and should make the ''selected'' line invisible.


SV sve February 15, 2005 02:02 PM UTC

The problem is i want to use alphaBlend for column but not the line. If i set AlphaBlendSelectionColor to 0 i dont show the selected columns... but it''s fine for my line. Is it possible to define alphablend for a particular selection ?


SV sve February 15, 2005 02:07 PM UTC

If is not possible may be the solution is to manage the selected line with the currency manager ?


AD Administrator Syncfusion Team February 15, 2005 03:17 PM UTC

You can turn off the alphablend and use PrepareViewStyleInfo to color a selected column. this.gridDataBoundGrid1.AlphaBlendSelectionColor = System.Drawing.Color.FromArgb(0, 178, 180, 191);
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0 
		&& this.gridDataBoundGrid1.Selections.GetSelectedRows(true, true).AnyRangeContains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))) 
	{
		e.Style.BackColor = Color.DodgerBlue;
	}
}


SV sve February 15, 2005 03:28 PM UTC

This code works but it color my current line and not the column.


SV sve February 15, 2005 03:35 PM UTC

Ok it works with GetSelectedCols this.gridDataBoundGrid1.Selections.GetSelectedCols(true, true).AnyRangeContains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))) { e.Style.BackColor = Color.DodgerBlue; } } But the column is selected if i click on a cell on the grid and i want the column select just when i click on the header of the column. I try to resolve this problem, thanks for response.

Loader.
Up arrow icon