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

grid row selection problem

Hi there,

I have a grid and i want a row to be selected and show the selection color when the user presses a row.
The problem is that i get the row selected as a whole but the cell get's a different color. (pic attached)

What are the settings,styles and such to achive this ?

p.s
the cells are not editable.

Thanks
0L


badselection.zip

5 Replies

AD Administrator Syncfusion Team November 14, 2006 09:37 AM UTC

Hi OL,

If you want to highlight the current cell, you can handle the PrepareViewSyleInfo event and set the style for the currentcell. Here is a code snippet,

private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if( cc.RowIndex == e.RowIndex && e.ColIndex == cc.ColIndex)
{
e.Style.BackColor = grid.AlphaBlendSelectionColor;
e.Style.Borders.All = new GridBorder(GridBorderStyle.Solid);
}
}

Best Regards,
Haneef


OL Omry Levy November 14, 2006 12:45 PM UTC

Haneef thanks for your quick reply,

I dont want to highlight the current cell, i want it to not be highlighted when it is clicked upon !

I've attached a picture and in it you can see that although the row is selected and shows the selection color , the cell shows the selection color when it is clicked, it can not be edited, i want only the row to be selected not the cell

How do i achive that ?

Thanks
0L


AD Administrator Syncfusion Team November 15, 2006 09:17 AM UTC

Hi OL,

Try setting the ListBoxSelectionMode property to SelectionMode.One.

this.grid.ListBoxSelectionMode=SelectionMode.One;

Regards,
Haneef


OL Omry Levy November 19, 2006 09:36 AM UTC

Hi Haneef,

Your suggestion of setting the SelectionMode to One is alreay what i did.

The cell can not be edited, the grid only show data, the problem is that the selected cell changes his color and i want it to appear as the selected row color.

What are the properties that change the current cell colors when it is selected, can i do it from there ?

Please look at the attached image again to understand what the problem is.

Thanks
0L


badselection0.zip


AD Administrator Syncfusion Team November 21, 2006 11:56 AM UTC

Hi OL,

The HighlightCurrentRow ( \Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Windows\Samples\Quick Start\HighlightCurrentRow\ ) browser sample shows you how to highlight the current row in a grid. It avoids the problems that arise as you traverse the various grid states as the old current cell deactivates and the new current cell becomes active. It uses a PrepareViewStyleInfo event handler to actually modify the style of any cell that is in the current row to display a highlighted cell. It uses the CurrentCellDeactivated and the CurrentCellActivated events to force the redraw of the old current row and the new current row so that only the proper row is ultimately highlighted. There are also other event handlers that are shown for other points in the flow sequence that occurs during a current cell move.

Here is a path.
[install path]\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Windows\Samples\Quick Start\HighlightCurrentRow

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon